1.我想在群组页面显示来自已加入群组的成员的消息。
2.然后,我写了如下代码,
(show.html.erb-group)
<% @group_messages.each do |gm| %>
<div class="message_area">
<p class= "member_name"><a href="/members/<%= gm.member_id %>">
<%= gm.member_id %></a></p>
<p class="message_content"><%= gm.content %></p>
<p class="message_create">(<%= gm.created_at.strftime'%Y-%m-%d %H:%M' %>)
</p></div>
</tr>
<% end %>
(groups_controller)
def show
@group = Group.find(params[:id])
if !checklogin? then return end
groupfriends = GroupInMember.where(:member_id => session[:login].id)
gflist = '('
groupfriends.each do |gf|
gflist += gf.member_id.to_s + ","
end
gflist += session[:login].id.to_s + ')'
@query = "select * from group_in_members where member_id in " + gflist
@group_messages = GroupMessage.find_by_sql(@query)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @group_messages }
end
respond_to do |format|
format.html # show.html.erb
format.json { render json: @group }
end
end
3.然后,我收到这样的错误消息
missing attribute: content
Extracted source (around line #23):
20: <div class="message_area">
21: <p class= "member_name"><a href="/members/<%= gm.member_id %>">
22: <%= gm.member_id %></a></p>
23: <p class="message_content"><%= gm.content %></p>
24: <p class="message_create">(<%= gm.created_at.strftime'%Y-%m-%d %H:%M' %>)
25: </p></div>
26: </tr>
4.我该如何解决这个问题?你能给我一个提示吗?