从头开始研究我的第一个json,我似乎无法想出这个简单的部分

时间:2010-06-29 20:14:15

标签: jquery ruby-on-rails ruby json haml

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>):

1 个答案:

答案 0 :(得分:0)

看起来错误与haml或json有关 - 我认为它在@ organization.accumulated_credits赋值中;看起来它不存在

您能否确认存在(通过schema.rb或使用控制台?)

@organization.update_attribute('accumulated_credits', '0')
...
NoMethodError (undefined method `accumulated_credits=' for #<Organization:0x2f3242c>):