How to use seed data with Paperclip + S3

I am trying to seed my database with member profiles as well as member profile photos with S3 and paperclip, but it does not seem to work.

I can create / edit existing elements in the application to add images using paperclip + S3, and it works fine, but the sowing does not work. I searched, but cannot find the answer.

+8
ruby-on-rails-3 rubygems seed paperclip
source share
1 answer

I don't know what your exact problem is, but you can try something like this in the seeds.rb file:

u = User.new({:name => 'username', :email => 'user@name.fr'...}) u.avartar = File.open('/Users/myAccount/avatars/user.png') u.save! 

In your User.rb file, you must have a parcelclip configured to work with amazon s3

 has_attached_file :avatar, :styles => { :large => "177x177>", :thumb => "60x60>" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => "/avatars/:style/:id/:filename" 

You can find in dogan kaya berktas blog post about s3.yml

+12
source share

All Articles