views:

24

answers:

1

I have these models:

Person

has_many :messages_form_person, :foreign_key => :from_user_id, :class_name => :messages
has_many :messages_to_person,     :foreign_key => :to_user_id, :class_name => :messages

Message

belongs_to :to_person, :foreign_key     => :to_user_id, :class_name => :person
belongs_to :from_person, :foreign_key   => :to_user_id, :class_name => :person

And this view:

person#show

<% @person.messages_to_person.each do |message| %>
  <%=h message.title %>
<% end %>

But I get this error:

TypeError in People#show

Showing app/views/people/show.html.erb where line #26 raised:

can't convert Symbol into String

Extracted source (around line #26):

23:   <%=h @person.biography %>
24: </p>
25: 
26: <% @person.messages_to_person.each do |message| %>
27: 
28: <% end %>
29: 

I basically want it so that people can send each other messages.

Can anyone help me? Thanks.

+3  A: 

The problem is :class_name should be a string

:class_name => "Message"
:class_name => "Person"
j.
Awesome! Thanks
Time Machine
You're welcome! You should accept the answer :]
j.
@j. I hate it that I must wait 10 minutes before I can accept an answer.
Time Machine
You have to wait? I'm sorry then :]
j.