ruby on rails - Carrierwave - development upload issues after adding S3/Fog for production -
i got production rails 3 app setup use fog/s3 storage while running on heroku. in process, made few changes /config/initializers/carrierwave.rb
. here's looks like:
carrierwave.configure |config| if rails.env.test? || rails.env.development? config.root = rails.root config.storage = :file else config.storage = :fog config.fog_credentials = { :provider => 'aws', # required :aws_access_key_id => env['my_id'], # required :aws_secret_access_key => env['my_key'] # required } config.fog_directory = 'my-app' # required config.fog_public = false # optional, defaults true #config.fog_attributes = {'cache-control'=>'max-age=315576000'} # optional, defaults {} end end
here's image_uploader
:
class imageuploader < carrierwave::uploader::base def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end end
uploads working fine in production. files being uploaded correct destination in development, error when viewing uploaded image:
actioncontroller::routingerror (no route matches [get] "/uploads/vendor/image/24/storeb.png"):
i'm unsure of how fix this. missing in uploader? please? let me know if need more info. in advance!
edit code example throws error:
<% @stores.each |s| %> <div class="row"> <div class= "col-xs-9 horz-cent"> <%= link_to image_tag("#{s.vendor.image}"), user_show_store_path(s) %> </div> </div> <% end %>
set config.root
below
config.root = rails.root.join('public')
currently files getting uploaded in rails.root
directory non accessible browser not in public
directory.
Comments
Post a Comment