How to use Seed data with Paperclip + S3

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.

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.

Answers


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


Need Your Help

Unable to load json file in html using d3.js

javascript html json d3.js bubble-chart

I want to load data from a json file in an HTML file and use D3 to visualize it. I am able to view the data in the browser if the file is loaded on its own. The file is also received correctly veri...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.