checkins.create({note:"This is another test"})
Our ultimate goal is to create a checkin record, so start there.
Location.first.checkins.create({note: "This is another test"})
Chain the code from Step One to an existing instance of one of the available polymorphable models (either Event or Location, in this case).
user.checkins << Location.first.checkins.create({note: "This is another test"})
Per section 4.3.1 of the Active Record Associations RailsGuide,
When you declare a
has_and_belongs_to_many
association, the declaring class automatically gains 16 methods related to the association:
...
collection<<(object, ...)
...