<やりたいこと>
index.html.erbのlink_toでリンクを表示させたい
<困っていること>
リソースのネストはできていると思うが、link_toの書き方が間違っているのかエラーになってしまう。
<質問>
おそらくlink_toの後のコードの書き方が間違っていると思うのですが、どう書いたらいいのかわからないので参考になるサイトやアドバイスなどありましたら教えていただけないでしょうか?
tasks/index.html.erb
<table class="table table-hover" id="table-tasks"> <thead> <tr> <th><%= Task.human_attribute_name :name %></th> <th><%= Task.human_attribute_name :details %></th> <th></th> </tr> </thead> <tbody> <% @tasks.each do |task| %> <tr> <td><%= link_to task.name, task %></td> <td><%= task.created_at %></td> <td></td> </tr> <% end %> </tbody> </table>
tasks_controller.rb
def index @tasks = Task.all end
routes.rb
resources :users do resources :tasks end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/08 02:40