how to link to a nested route path inside a loop?

前端 未结 1 1264
失恋的感觉
失恋的感觉 2021-01-27 20:48

In my application I have stories and substories. Substories are nested inside stories and on the storiesindex.html.erb. I\'m looping trough all the

相关标签:
1条回答
  • 2021-01-27 21:26
    <% story.substories.each do |substory| %>
        <%= substory.title %>
        <%= substory.subplot %>
    
        <% if substory %>
            <%= link_to 'Edit', edit_story_substory_path(substory.story, substory) %>
        <% end %>
    
    <% end %>
    

    You just made a typo. @substory would work too if you declare it on your Stories#index

    0 讨论(0)
提交回复
热议问题