2010-06-29 22 views
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>): 

回答

0

看起来不像是haml或json相关的错误 - 我认为它在@ organization.accumulated_credits任务中;看起来它不存在

你能否证实存在(无论是通过schema.rb或使用控制台?)

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

啊哈!我只能在IRB中检索这些数据,比如Organization.first.accumulated_credits(返回0)。但是如果我做Organization.first.update_attribute('cumulative_credit','0'),它给了我与上面相同的错误。那是什么意思? – Trip 2010-06-29 20:23:36

+0

我明白了。这是因为这个属性没有附加到这个模型上。因此问题:D但是你的指针让我知道了。谢谢 – Trip 2010-06-29 20:33:44

相关问题