开发者

Multiple controllers with a single model

I'm setting up a directory application for which I need to have two separate interfaces for the same Users table. Basically, administrators use the Users controller and views to list, edit, and add user开发者_如何转开发s, while non-admins need a separate interface which lists users in a completely different manner. To do this, would I be able to just set up another controller with different views but which accesses the Users model?

Sorry if this is a simple question, but I've had a hard time finding how to do this.


Why not put the admin part into a separate namespace - you would have Admin::UsersController with views in app/views/admin/users/. And your users would go to UsersController with its own views in app/views/users/.

The routing is defined like this:

map.namespace :admin do |admin|
  admin.resources :users
end


map.resources :users

And can be got to via admin_users_path and users_path

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜