开发者

How to use Seed data with Paperclip + S3

I'm trying to seed my database with member profile开发者_如何学Gos and also member profile pictures with S3 and paperclip but it doesn't seem to be working.

I can create/edit existing members within the application to add pictures with paperclip + S3 and it works just fine but seeding it doesn't work. I have searched but can't find an answer.


I don't know what is your exact problem but you can try something like this in your 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 parperclip 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 could find on dogan kaya berktas blog post detail about s3.yml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜