rails using link_to with namespaced routes

前端 未结 3 786
野趣味
野趣味 2020-12-23 11:57

I\'ve created a set of routes & controllers with the admin namespace, and I was having some issues using the link helpers with these new routes.

I see that there

3条回答
  •  眼角桃花
    2020-12-23 12:53

    If you're using Rails 3, you can use your admin namespace with the variable instead of writing the long helper path name.

    view:

    <%= link_to 'Show', [:admin, project] %>
    <%= link_to 'Edit', [:edit, :admin, project] %>
    <%= link_to 'Destroy', [:admin, project], confirm: 'Are you sure?', method: :delete %>
    

    controller:

    redirect_to [:admin, @project]
    

提交回复
热议问题