Associations

This thing is driving me mad.

So, I’m following a typical exercise with Authors, Messages and Topics.

I’m coding with Rails 3.0.7 and Ruby 1.8.7.

The relation I want to do is really simple :

Author has_many :messages

Messages belongs_to :author
has_one :topic

Topic :has_one :author
:has_many :messages

the catch comes when on the console I’m inserting manually objects and
then verifying them.

So, for example, if I create a message named:
message1 = Message.new(:text => ‘this is a message’)

and an author like
jack = Author.new(:name => ‘Jack’)

the next thing I will try to do shall be:
message1.author = jack

So at this point, if I want to verify I do this:
message1.author
=> #<Author id: 8, name: “jack”, created_at: “2011-06-11 16:29:56”,
updated_at: “2011-06-11 16:29:56”>

Everything is fine.

But if I try to do the inverse, so :

jack.messages

I obtain this :

ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column:
messages.author_id: SELECT “messages”.* FROM “messages” WHERE
(“messages”.author_id = 8)

and I don’t understand what it means. :frowning:
Do you have any idea about where am I mistaken?