开发者

Rails 3 - routing for admin section

the structure of my admin section looks like this:

controlers -> admi开发者_如何学编程n -> admin_controllers...
views -> admin -> users -> data
views -> admin -> settings -> data

My routes looks like:

resources :users, :user_sessions
match 'login' => 'user_sessions#new', :as => :login
match 'logout' => 'user_sessions#destroy', :as => :logout

EDIT

  namespace :admin do
    ...      
    resources :users, :user_sessions
    match 'login' => 'user_sessions#new', :as => :login
    match 'logout' => 'user_sessions#destroy', :as => :logout
  end

But if I set up to the browser url address admin/login, so I will receive an error about missing template (especially Missing template user_sessions/new). How is it possible? What I forgot?

Thanks


to use namespaces, you have to use such shema:

namespace :admin do
  resources :users, :user_sessions
end

all that views should be in app/views/admin/, like this

app/views/admin/users/new.html.erb

the API details is here: http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜