HAML:
= link_to 'redeem', redeem_admin_organization_path(organization), :class => 'button_short live redeem'
控制器:
def redeem
@organization = Organization.find(params[:id])
@organization.update_attribute('accumulated_credits', '0')
end
redeem.js.haml:
== $("#organization_#{@organization.id} .redeem").html("#{escape_javascript(link_to('redeem', redeem_admin_organization_path(@organization), :class => 'button_short live redeem'))}");
这将返回错误:
NoMethodError (undefined method `accumulated_credits=' for #<Organization:0x2f3242c>):
答案 0 :(得分:0)
看起来错误与haml或json有关 - 我认为它在@ organization.accumulated_credits赋值中;看起来它不存在
您能否确认存在(通过schema.rb或使用控制台?)
@organization.update_attribute('accumulated_credits', '0')
...
NoMethodError (undefined method `accumulated_credits=' for #<Organization:0x2f3242c>):