jnicklas/carrierwave — Issue #493: asset_path in CarrierWave::Uploader::Base generates an error
Author: andrusha
Created: 2011-10-18 06:24:54+00:00
State: open

rails 3.1.1, sprockets 2.0.4, carrierwave 0.5.7

this snippet:

class PhotoUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
include CarrierWave::RMagick
# include CarrierWave::ImageScience
include Sprockets::Helpers::RailsHelper

# Provide a default URL as a default if there hasn't been a file uploaded:
def default_url
asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
end
end

generates following error:

NameError (undefined local variable or method `config' for :#):
/usr/lib/ruby/gems/1.9.1/gems/actionpack-3.1.1/lib/sprockets/helpers/rails_helper.rb:11:in `asset_paths'
/usr/lib/ruby/gems/1.9.1/gems/actionpack-3.1.1/lib/sprockets/helpers/rails_helper.rb:56:in `asset_path'
app/uploaders/photo_uploader.rb:23:in `default_url'
/usr/lib/ruby/gems/1.9.1/gems/carrierwave-0.5.7/lib/carrierwave/uploader/default_url.rb:8:in `url'
app/helpers/users_helper.rb:122:in `username_with_icon'