I was reading a book and following the instructions in it.
class Story < ActiveRecord::Base; end
story = Story.new
=> #<Story id: nil, name: nil, url: nil, created_at: nil,
=> Story(id: integer, name: string, link: string,
created_at: datetime, updated_at: datetime)
I do not remember me asking for id, name, link or url, created_at and
At some point you must have created a "stories" table in your database with those fields. Rails (technically ActiveRecord) finds this based on the name of your class (singular version of the table by default).
I do know if I typed craeted_at instead of created_at or
updetad_at instead of updated_at. How do I check whether i typed it
right or wrong?
It should complain about the method not being there.
From the Rails console, I had to create a story class, one instance of
it and save the object, but I created two, so I got a 2 output for a
story.id input. How do I remove the second object from the database?
Note that that '2' is the *id* of the record you want to remove. Has nothing to do with it being the 'second' object.