Last active
August 29, 2015 14:15
-
-
Save alexdunae/8136c4b01c9e6f996f52 to your computer and use it in GitHub Desktop.
IMG 240: Library seeds.rb
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
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