开发者

What should my admin/posts edit url look like?

开发者 https://www.devze.com 2023-01-30 16:05 出处:网络
My routes has: namespace :admin do resource :posts end I tried this link: <a href=\"<%= edit_admin_posts_path @post %>\">edit</a>

My routes has:

namespace :admin do
     resource :posts

  end

I tried this link:

<a href="<%= edit_admin_posts_path @post %>">edit</a>

it generates:

/admin/posts/edit.my-post-title

What should the edit page look like, rake routes shows this:

/admin/posts/edit(.:format)

not sure what tha开发者_如何学编程t format means?


I think you want to use resources, not resource. Using the singular form is not appropriate when you try to create a path by supplying a resource id.

With resources the path helper is:

edit_admin_post => GET /admin/posts/:id/edit(.:format)
  {:action=>"edit", :controller=>"admin/posts"}

and edit_admin_post_path(@post) should work.

:format refers to the various formats that the controller might respond with, i.e .html, .xml, etc

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号