当我在<代码>上填写时,js.erb www.un.org/Depts/DGACM/index_french.htm
$( div#rewards_list ).html("<%=
escape_javascript(render :partial => shared/rewards ,
:collection => @rewards,
:as => reward,
:locals => { :user => @user }
)
%>");
但该记录表明:
ActionView::Template::Error (undefined local variable or method `reward for
#<#<Class:0xbb395d8>:0xbb3774c>):
在我更新的行动方法中:
def update
@user = User.find(params[:user_id])
@reward = @user.rewards.find(params[:id])
respond_to do |format|
if @reward.update_attributes(params[:reward])
@rewards = @user.rewards
format.html { redirect_to @user }
format.js
else
flash[:error] = "There is an error while updating the reward, please try again!"
format.html { redirect_to @user }
end
end
end