Skip to content

Instantly share code, notes, and snippets.

@ahimmelstoss
Created May 14, 2014 17:46
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 ahimmelstoss/25e359a760395ecfec5b to your computer and use it in GitHub Desktop.
Save ahimmelstoss/25e359a760395ecfec5b to your computer and use it in GitHub Desktop.
host_user = User.new
host_user.name = "Host User"
host_user.save
guest_user = User.create(:name => "Guest User")
not_attending_user = User.create(:name => "Not Attending User")
attending_user = User.create(:name => "Attending User")
birthday = Event.create(:name => "Birthday", :host => host_user)
holiday_party = host_user.hosted_events.create(:name => "Holiday Party")
# birthday.host_id = 1 # 2 details, column and literal value
# birthday.host_id = host_user.id # 1 detail, column
# birthday.host = host_user # 0 details, just an attribute
Invite.create(:event => birthday,
:guest => guest_user,
:status => true)
birthday.invites.create(:guest => not_attending_user, :status => false)
attending_user.invites.create(:event => holiday_party, :status => true)
birthday.guests << guest_user
holiday_party.guests << guest_user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment