使用rake路径显示的路径方法仍未定义

时间:2013-02-03 16:19:46

标签: methods path routes ruby-on-rails-3.2

在摆脱这个question之后,我得到了另一个。

我在路由resources :tree_nurseries do ...中指定了路径方法。并且当我执行rake routes时会正确显示new_tree_nursery,然后通常new_tree_nursery_path将可用。

但是,当我用link_to方法调用它时,它仍然是不可取的....(new_tree_nursery_path

我又错过了什么?

这是代码行:

.actions
  = link_to t('.new', :default => t("helpers.links.new")), new_tree_nursery_path, :class => 'btn btn-primary pull-right'

rake路线结果为:

               tree_nurseries GET    /tree_nurseries(.:format)                     tree_nurseries#index
                          POST   /tree_nurseries(.:format)                     tree_nurseries#create
         new_tree_nursery GET    /tree_nurseries/new(.:format)                 tree_nurseries#new
        edit_tree_nursery GET    /tree_nurseries/:id/edit(.:format)            tree_nurseries#edit
             tree_nursery GET    /tree_nurseries/:id(.:format)                 tree_nurseries#show
                          PUT    /tree_nurseries/:id(.:format)                 tree_nurseries#update
                          DELETE /tree_nurseries/:id(.:format)                 tree_nurseries#destroy

config / environment.rb:

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'tree_nursery', 'tree_nurseries'
end

0 个答案:

没有答案