开发者

Problem using on_the_spot gem with rails 3 and newly created records

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=开发者_StackOverflow中文版>"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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜