Skip to content

Instantly share code, notes, and snippets.

@MikeRogers0
Created January 27, 2015 13:52
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 MikeRogers0/640980264e980b52bab0 to your computer and use it in GitHub Desktop.
Save MikeRogers0/640980264e980b52bab0 to your computer and use it in GitHub Desktop.
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