我创建了一个设计用户模型。有两种类型的用户:
- 顾客
- 行政
我已经完成了 bij 创建两个“正常”模型:客户和管理员。这两个模型继承自用户模型,如下所示:
class Customer < User
有谁知道我如何为每种类型的用户设置根路径。我想要这样的东西:
authenticated :customer do
root :to => "customer/dashboard#index"
end
authenticated :admin do
root :to => "admin/dashboard#index"
end
更新:
我已经解决了这个问题:
root :to => "pages#home", :constraints => lambda { |request|!request.env['warden'].user}
root :to => 'customer/dashboard#index', :constraints => lambda { |request| request.env['warden'].user.type == 'customer' }
root :to => 'admin/dashboard#index', :constraints => lambda { |request| request.env['warden'].user.type == 'admin' }