Rails 3 link_to routes (edit) nested resources

后端 未结 3 583
旧时难觅i
旧时难觅i 2021-01-05 05:18

Sorry if this has been asked elsewhere, but I can\'t figure this out. I have a forum with sections, topics, and replies. I\'m trying to edit and delete replies from the show

3条回答
  •  时光取名叫无心
    2021-01-05 05:46

    I really dislike this aspect of the link_to helper. In the interest of making your code more readable and less prone to error, I would suggest that you be explicit about which IDs you are passing in.

    <%= link_to 'Edit', edit_section_topic_reply_path(:id => @reply.id, 
                                                      :topic_id => @topic.id, 
                                                      :section_id => @section.id) %>
    

    I've run into too many subtle and seemingly insane bugs due to params being out of order in a link_to.

提交回复
热议问题