我有这些模特:
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
belongs_to :to_person, :foreign_key => :to_user_id, :class_name => :person
belongs_to :from_person, :foreign_key => :to_user_id, :class_name => :person
这个观点:
<% @person.messages_to_person.each do |message| %>
<%=h message.title %>
<% end %>
但是我收到了这个错误:
People#show
中的TypeError显示第26行引出的app / views / people / show.html.erb:
can't convert Symbol into String
提取的来源(在#26 附近):
23: <%=h @person.biography %> 24: </p> 25: 26: <% @person.messages_to_person.each do |message| %> 27: 28: <% end %> 29:
我基本上想要它,以便人们可以互相发送消息。
任何人都可以帮助我吗?感谢。
答案 0 :(得分:3)
问题是:class_name
应该是string
:class_name => "Message"
:class_name => "Person"