使用on_the_spot gem与rails 3和新创建的记录存在问题 [英] Problem using on_the_spot gem with rails 3 and newly created records

查看:81
本文介绍了使用on_the_spot gem与rails 3和新创建的记录存在问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用on_the_spot gem来编辑渲染表中的某个列。这工作正常。
但是,当我创建一个新记录并使用AJAX更新表时,我收到以下错误消息:

ActionView :: Template :: Error匹配{:action =>update_attribute_on_the_spot,:controller =>stores_spare_parts}):



如何解决这个问题? b

解决方案

从代码中我看不出明显的错误。我猜这是错误的是,提到的路线确实没有定义。我认为这是不可能的,因为它在 index -view中工作,但是如果索引视图属于不同的控制器,例如商店和创建 store_spare_part 到他的控制器,这是一个可能的解决方案。但是,这只是一个猜测。



所以你的路线中有以下几条:

  resources:stores_spare_parts do 
collection do
post:update_attribute_on_the_spot
end
end

利用我现在的信息,这是我能想到的唯一合乎逻辑的解释。



我忘了,但 on_the_spot gem可以选择明确指定 url 。目的是能够提供/使用您自己的方法,但也可以在这种情况下使用它。

用法:

  on_the_spot_edit后,:title,:url = > url_for({:controller =>'stores / store_spare_parts',:action =>:update_attribute_on_the_spot})

它仍然很奇怪,应该需要,但我希望这是一个有效的解决方法。


I am using the on_the_spot gem for editing a certain column in a rendered table. This works fine. But when I create a new records and update the table using AJAX I get the following error message:

"ActionView::Template::Error (No route matches {:action=>"update_attribute_on_the_spot", :controller=>"stores_spare_parts"}): "

How can I solve this problem?

解决方案

From the code i see no obvious error. What i guess that is wrong is that the mentioned route is indeed not defined. I would assume that was not possible, because it works in the index-view, but if the index-view belongs to a different controller, e.g. the store, and creating the store_spare_part goes to his controller, than that is a possible solution. But this is just a guess.

So do you have the following in your routes:

resources :stores_spare_parts do
  collection do
    post :update_attribute_on_the_spot
  end
end

With the information i have now, this is the only logical explanation i can think of. I hope it helps.

[EDIT: found another workaround] I forgot, but the on_the_spot gem has the option to explicitly specify the url. The intention was to be able to supply/use your own method, but it could also be used in this case.

Usage:

on_the_spot_edit post, :title, :url => url_for({:controller => 'stores/store_spare_parts', :action => :update_attribute_on_the_spot})

It still remains weird that it should be needed, but I hope this is a valid workaround.

这篇关于使用on_the_spot gem与rails 3和新创建的记录存在问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆