Skip to content

Instantly share code, notes, and snippets.

@alexdunae
Last active August 29, 2015 14:15
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 alexdunae/8136c4b01c9e6f996f52 to your computer and use it in GitHub Desktop.
Save alexdunae/8136c4b01c9e6f996f52 to your computer and use it in GitHub Desktop.
IMG 240: Library seeds.rb
puts 'Clearing any existing Item data...'
Item.destroy_all
# Learn about how `find_or_create_by` works:
# http://apidock.com/rails/v4.0.2/ActiveRecord/Relation/find_or_create_by
puts 'Adding item types...'
ItemType.find_or_create_by!(name: 'Magazine Article')
ItemType.find_or_create_by!(name: 'Book')
ItemType.find_or_create_by!(name: 'Movie')
ItemType.find_or_create_by!(name: 'TV Show')
puts 'Done.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment