Note that there are some explanatory texts on larger screens.

plurals
  1. POCarrierWave can't convert nil into String
    text
    copied!<p>I just want to do a simpel image upload with carrierwave, uploading works so far(at least that's what I think), but when I try to get the image with </p> <pre><code>on "/entries" do entries = Entry.all entries.each do |entry| @foobar = "#{@foobar} entry.image.url" end "#{@foobar}" end </code></pre> <p>I just get the following error</p> <pre><code>TypeError - can't convert nil into String: /home/peer/.gem/ruby/1.9.1/gems/carrierwave-0.6.2/lib/carrierwave/uploader/url.rb:22:in `expand_path' /home/peer/.gem/ruby/1.9.1/gems/carrierwave-0.6.2/lib/carrierwave/uploader/url.rb:22:in `url' /home/peer/.gem/ruby/1.9.1/gems/carrierwave-0.6.2/lib/carrierwave/uploader/versions.rb:159:in `url' /home/peer/.gem/ruby/1.9.1/gems/carrierwave-0.6.2/lib/carrierwave/uploader/default_url.rb:8:in `url' /home/peer/.gem/ruby/1.9.1/gems/carrierwave-0.6.2/lib/carrierwave/uploader/url.rb:27:in `to_s' /home/peer/Project/myapp/controllers/view_entries.rb:4:in `block in &lt;top (required)&gt;' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1212:in `call' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1212:in `block in compile!' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in `[]' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in `block (3 levels) in route!' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:801:in `route_eval' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in `block (2 levels) in route!' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:822:in `block in process_route' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:820:in `catch' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:820:in `process_route' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:784:in `block in route!' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:783:in `each' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:783:in `route!' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:886:in `dispatch!' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:719:in `block in call!' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in `block in invoke' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in `catch' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in `invoke' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:719:in `call!' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:705:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context' /home/peer/.gem/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-1.4.1/lib/rack/logger.rb:15:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-1.4.1/lib/rack/head.rb:9:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/showexceptions.rb:21:in `call' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in `block in call' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1416:in `synchronize' /home/peer/.gem/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in `call' /home/peer/.gem/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service' /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service' /usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run' /usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread' </code></pre> <p>Here is my entry model:</p> <pre><code>class ImageUploader &lt; CarrierWave::Uploader::Base def store_dir "public/user_uploads" end def extensions_white_list %w(jpg jpeg gif png) end storage :file end class Entry include DataMapper::Resource property :id, Serial property :text, Text property :created_at, String mount_uploader :image, ImageUploader belongs_to :user end </code></pre> <p>So I have absolutly no idea what is wrong here...</p> <p><strong>Why is it not possible to get the url of the image?</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload