开发者

Ruby on Rails 3 - Routing

I am writing a rails application and getting stuck on a routing issue.

My application allows a user to manage multiple cause pages (for various reasons)

right now, I am trying to build the admin screens for users to update their site.

for example, cause pages could look like:

.com/causes/1
.com/causes/2

I and want the admin URL to be:

.com/causes/1/admin/updates
.com/causes/2/admin/updates

etc.

How would I setup my routes to do thi开发者_C百科s

I originally thought something like:

namespace "admin" do
  resources :updates
end

But how can I prefix that with the cause/:id so that I can relate which cause I am updating?


You will need to have an admin_controller of sorts and you can setup your routes like so:

resources :admin do
  #insert any resource you need to have admin pages on here
  resources :causes do
    resources :updates do
    end
  end
end

something like that. Or you could try some rails admin gems to make your life easier like: http://www.activescaffold.com/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜