我有一个渲染:
= render :partial => 'friendship/friends', :collection => @friendships.find_all{|item| item.friend.friends.include?(current_user)}
渲染代码为:
= content_tag_for(:tr,friendship) do
%td
=link_to friendship.friend do
.post_image.fl_l
=image_tag friendship.friend.avatar.url(:thumb)
=friendship.friend.name
=friendship.friend.surname
%br
=link_to "remove",friendship,:method => :delete
它输出此错误:
> undefined local variable or method `friendship' for
> #<#<Class:0x5ce61b8>:0x5ce35c0>
在我的控制器动作中我有
@friendships = current_user.friendships
@users_friended =current_user.inverse_friends
respond_to do |format|
format.html
format.js
我对消息
做了同样的事情 = render :partial => 'messages/message', :collection => @messages_received
渲染代码
= content_tag_for(:tr,message) do
....
控制器动作
@user = User.find(params[:id])
@messages_received=@user.received_messages.reverse
@messages_sent=@user.sent_messages.reverse
respond_to do |format|
format.html
format.js
它工作正常。我认为我也是这样做的,但它不起作用。我做错了什么?