undefined method exception if no data is present

I get this error if no relational data is present:   undefined method `notes' for #<Array:0x226cc4c>

Here is the code that causes the error:   @notes = @account.notes

If I call this method through the script/console I get account = Account.find(3) => #<Account id: 3, ...>

account.notes

=>

I get the same error if I don't declare the @notes var and access the notes collection through the controller within the haml template ie @account.notes.each do |n| ...

I am puzzled.

Thanks for the help

It looks like your trying to call a notes method on an instance of an Array. I don't think Arrays have a notes method.

Chris Olsen wrote:

Right you are. It was a mistype of :all rather than :first in the lookup.

Thanks