2017-05-19 5 views
-1

このRailsアプリでは、ユーザーはストーリーを書く。ストーリーはコレクションの一部である場合があります。コレクションは、コレクションを作成したユーザーに属します。各doループのLink_toパスが機能しない

私は、それが含まれているコレクションへのリンクを含む単一のストーリーを表示しようとしています。 collection.nameの部分は動作しますが、私はcollection_pathの権利を取得できません。ご協力いただきありがとうございます。

の物語/ show.html.erbコレクションの助けを借りて、以下を使用して、それを解決

user_collections GET /users/:user_id/collections(.:format)   collections#index 
         POST /users/:user_id/collections(.:format)   collections#create 
    new_user_collection GET /users/:user_id/collections/new(.:format)  collections#new 
    edit_user_collection GET /users/:user_id/collections/:id/edit(.:format) collections#edit 
     user_collection GET /users/:user_id/collections/:id(.:format)  collections#show 

routes.rbを

resources :users do 
     resources :collections 

答えて

0

ため

<% @story.collections.each do |collection| %> 
    <%= link_to collection.name, collection_path %> 
    <% end %> 

すくいルートこれに早く答えたセバスティアン・パルマ。

<% @story.collections.each do |collection| %> 
     <%= link_to collection.name, user_collection_path(collection.user, collection), class: 'btn btn-lake' %> 
     <% end %> 
関連する問題