Skip to content

Instantly share code, notes, and snippets.

@wacaw
Created October 16, 2014 13:18
Show Gist options
  • Save wacaw/d992717701633a30d5d8 to your computer and use it in GitHub Desktop.
Save wacaw/d992717701633a30d5d8 to your computer and use it in GitHub Desktop.
Generate factories from existing model
#run in rails console and paste in comand line to generate
Rails.application.eager_load!
ActiveRecord::Base.descendants.map do |f|
columns = f.columns.collect{|c| "#{c.name}:#{c.type}" }.join(' ')
puts "rails g factory_girl:model #{f} #{columns}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment