Skip to content

Instantly share code, notes, and snippets.

@MikeRogers0 MikeRogers0/seeds.rb
Created Jan 27, 2015

Embed
What would you like to do?
The methods I use with seedbank to easily add new seeds with a nice message.
class Seeds
def self.add model, attrs
object = model.find_or_initialize_by(attrs)
if object.new_record? && object.save
puts "#{object}"
end
end
end
after :farms do
puts 'Adding Users:'
farm = Farm.find_by name: 'McCain'
Seeds.add User, full_name: 'Mr McCain', is_manager: true, farm: farm
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.