views:

89

answers:

1

The "association?" query method that the Rails docs say should exist when I create a belongs_to association doesn't actually get created:

class Author < ActiveRecord::Base
  has_many :posts
end
class Post < ActiveRecord::Base
  belongs_to :author
end
>> p = Post.create(:author => Author.create)
>> p.author?
NoMethodError: undefined method `author?' for #<Post:0x2555d28>

Is this a bug, are the docs wrong, or am I doing something wrong?

+1  A: 

Take the question mark off.

p.author
Andy Gaskell
Of course that works, but the question is why does "author?" not work. It's documented that it should.
KingPong