如何使用Paperclip + S3使用种子数据 [英] How to use Seed data with Paperclip + S3
问题描述
我尝试使用S3和paperclip为会员资料和会员个人资料图片创建数据库,但它似乎没有工作。
I'm trying to seed my database with member profiles and also member profile pictures with S3 and paperclip but it doesn't seem to be working.
我可以创建/编辑应用程序中的现有成员添加回形针+ S3图片,它工作得很好,但播种不起作用。我已经搜索,但无法找到答案。
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.
推荐答案
我不知道你确切的问题是什么,但你可以尝试像这样在你的seeds.rb文件中:
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!
在您的User.rb文件中,您必须将parperclip配置为与amazon s3一起使用
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"
你可以在 dogan kaya berktas博客文章有关s3.yml的详细信息
You could find on dogan kaya berktas blog post detail about s3.yml
这篇关于如何使用Paperclip + S3使用种子数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!