Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 从头开始编写我的第一个json,但我似乎无法理解这个简单的部分_Jquery_Ruby On Rails_Ruby_Json_Haml - Fatal编程技术网

Jquery 从头开始编写我的第一个json,但我似乎无法理解这个简单的部分

Jquery 从头开始编写我的第一个json,但我似乎无法理解这个简单的部分,jquery,ruby-on-rails,ruby,json,haml,Jquery,Ruby On Rails,Ruby,Json,Haml,哈默: 控制器: = link_to 'redeem', redeem_admin_organization_path(organization), :class => 'button_short live redeem' 赎回.js.haml: def redeem @organization = Organization.find(params[:id]) @organization.update_attribute('accumulated_credits', '0') e

哈默:

控制器:

= link_to 'redeem', redeem_admin_organization_path(organization), :class => 'button_short live redeem'
赎回.js.haml:

def redeem
  @organization = Organization.find(params[:id])
  @organization.update_attribute('accumulated_credits', '0')
end
这将返回错误:

== $("#organization_#{@organization.id} .redeem").html("#{escape_javascript(link_to('redeem', redeem_admin_organization_path(@organization), :class => 'button_short live redeem'))}");

看起来错误与haml或json无关-我认为它在@organization.cumulated_credits分配中;看起来它不存在

您是否可以通过schema.rb或使用控制台来确认是否存在

NoMethodError (undefined method `accumulated_credits=' for #<Organization:0x2f3242c>):

啊哈!我只能在IRB中检索此数据,例如Organization.first.Consumerated_credits返回0。但是如果我做Organization.first.update_属性'Cumultived_credit','0',它会给出与上面相同的错误。那是什么意思?我明白了。这是因为此属性未附加到此模型。因此问题是:D,但你的指针让我明白了。谢谢
@organization.update_attribute('accumulated_credits', '0')
...
NoMethodError (undefined method `accumulated_credits=' for #<Organization:0x2f3242c>):