0
HAML:工作在我从头第一JSON和我似乎无法弄清楚这个简单的一部分了
= 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>):
啊哈!我只能在IRB中检索这些数据,比如Organization.first.accumulated_credits(返回0)。但是如果我做Organization.first.update_attribute('cumulative_credit','0'),它给了我与上面相同的错误。那是什么意思? – Trip 2010-06-29 20:23:36
我明白了。这是因为这个属性没有附加到这个模型上。因此问题:D但是你的指针让我知道了。谢谢 – Trip 2010-06-29 20:33:44