Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8132535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:22:26+00:00 2026-06-06T09:22:26+00:00

I just want to do a simpel image upload with carrierwave, uploading works so

  • 0

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

on "/entries" do

entries = Entry.all

entries.each do |entry|
  @foobar = "#{@foobar} entry.image.url"
end

"#{@foobar}"

end

I just get the following error

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 <top (required)>'
        /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'

Here is my entry model:

class ImageUploader < 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

So I have absolutly no idea what is wrong here…

Why is it not possible to get the url of the image?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:22:28+00:00Added an answer on June 6, 2026 at 9:22 am

    You should initialize @foobar before the following code:

    entries.each do |entry|
      @foobar = "#{@foobar} entry.image.url"
    end
    

    Be aware that @foobar will take the value of the last entry image url.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that Silverlight 3.0 has binding but just want a simple example on
I just want a simple SVG image that has some arbitrary text on an
I want to make a simple image viewing program, that just takes the images
It's really simple, I just want one screen. Wow, that [shiny thing] must have
Really simple but just not getting it. I want to reference a view by
I just started with Android and I'm doing a simple app that I want
Maybe it is very simple, but I did found the solution. I just want
I just want to add a side menu that links to various pages on
I want to do a simple image animation.Assume that there is small image of
Rails 3.1, ActiveRecord, JQuery I am using Carrierwave to upload an image to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.