Skip to content

Instantly share code, notes, and snippets.

@eveadele
Created April 17, 2014 19:22
Show Gist options
  • Save eveadele/11006104 to your computer and use it in GitHub Desktop.
Save eveadele/11006104 to your computer and use it in GitHub Desktop.
Seed Script
# assuming email addresses are unique and other User attributes are first_name, last_name,
# city, and state
User.find_or_create_by(email: "john.smith@gmail.com").update(first_name: "John", last_name: "Smith", city: "Quincy", state: "MA")
User.find_or_create_by(email: "jill.bob@yahoo.com").update(first_name: "Jill", last_name: "Bob", city: "Randolph", state: "MA")
User.find_or_create_by(email: "jane.doe@google.com").update(first_name: "Jane", last_name: "Doe", city: "Canton", state: "MA")
User.find_or_create_by(email: "johnny.bolo@sam.com").update(first_name: "Johnny", last_name: "Bolo", city: "Sharon", state: "MA")
User.find_or_create_by(email: "bill.james@gmail.com").update(first_name: "Bill", last_name: "James", city: "Canton", state: "MA")
User.find_or_create_by(email: "jim.mcmanus@gmail.com").update(first_name: "Jim", last_name: "McManus", city: "Quincy", state: "MA")
# SELECT * FROM users WHERE users.city IS "Canton" AND users.state IS "MA";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment