Created
January 27, 2015 13:52
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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