4
<%= link_to t('.new', :default => t("helpers.links.new")), new_equipment_path, :class => 'btn btn-primary' %>

上記のコードをビューに表示していますが、リンクをクリックすると次のエラーが発生します。No route matches {:action=>"show", :controller=>"equipment"}

私のルートファイルには次のものが含まれています。

resources :equipment

resources :workouts

match ':controller(/:action(/:id))(.:format)'

なぜショーアクションにアクセスしようとしているのですか?

これが私のルートからのエントリです:

   equipment_index GET        /equipment(.:format)                   equipment#index
                   POST       /equipment(.:format)                   equipment#create
     new_equipment GET        /equipment/new(.:format)               equipment#new
    edit_equipment GET        /equipment/:id/edit(.:format)          equipment#edit
         equipment GET        /equipment/:id(.:format)               equipment#show
                   PUT        /equipment/:id(.:format)               equipment#update
                   DELETE     /equipment/:id(.:format)               equipment#destroy
4

3 に答える 3

0

routes.rbに「s」を追加しequimentてみましたか?

resources :equipments
于 2012-07-07T13:24:51.030 に答える
0

機器は数えられない名詞と見なされるため、語形変化を使用してこれを解決できるはずです。

変曲に関するレールのドキュメントでは、実際にその例の一部として機器を使用しています。

以下を に追加しますconfig/initializers/inflections.rb

ActiveSupport::Inflector.inflections do |inflect|
  inflect.uncountable 'equipment'
end

追加情報: Rails 3 リソース ルーティングの不可算名詞

于 2015-09-04T19:50:35.287 に答える