自动生成轨道3中的路径? [英] autogenerate paths in rails 3?
问题描述
从某些railscast的外观(特别是),它看起来像有一些自动生成的* _path变量不会发生在我身上。在这个rails投射中,edit_mutliple_products_path似乎是自动生成的(我通常不喜欢使用那个单词)。当我按照相同的步骤尝试访问类似的路径时,我得到了这个:
From the looks of some railscasts (this one in particular), it seems like there is some autogeneration of "*_path" variables that not happening for me. in this rails cast, the edit_mutliple_products_path seems to be generated automagically (i don't normally like using that word). When I follow through the same steps and try to access a similar path, i get this:
undefined local variable or method `edit_multiple_distributions_workflows_path' for #<#<Class:0x132b18a68>:0x132af3290>
推荐答案
这是rails 2.X.在Rails 3中Rails路由改变了,为了得到这个路由,添加到routes.rb:
This is rails 2.X. Rails routes changed in Rails 3. in order to get this route add below to routes.rb:
resources :products do
collection do
post 'edit_multiple'
put 'update_multiple'
end
end
您可以使用
You will be able to access this paths with
edit_multiple_products_url
edit_multiple_products_path
update_multiple_products_url
update_multiple_products_path
而不是 edit_multiple_distributions_workflow_path
。顺便说一句你从哪里得到这条路?我没有在railscast中看到它。
instead of edit_multiple_distributions_workflow_path
. Btw where did you get this path from? I did not see it in the railscast.
这篇关于自动生成轨道3中的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!