Skip to content

Instantly share code, notes, and snippets.

@barce
Created October 29, 2013 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barce/7219798 to your computer and use it in GitHub Desktop.
Save barce/7219798 to your computer and use it in GitHub Desktop.
code for creating a seeds.rb file from user objects
namespace :export do
desc "Prints seeds in a seeds.rb format"
task :seeds_format => :environment do
User.order(:id).all.each do |user|
# doesn't work on dreamhost
puts "User.create(#{user.serializable_hash.delete_if { |key, value| ['created_at','updated_at','id'].include?(key)}.to_s.gsub(/[{}]/,'')})"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment