You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello.
I trying redirect users to a root path based on their roles, using this method and based on this docs.
authenticated:admin,lambda{ |u| u.has_role?:admin}doroot:to=>'users#index',:as=>:admin_rootendauthenticated:operator,lambda{ |u| u.has_role?:operator}doroot:to=>'tasks#index',:as=>:operator_rootendauthenticateddo# all other rolesroot:to=>'users#show',:as=>:user_rootend
Then I go to root path, server always send me users#show.
Moreover, log says that has_role? method not called, it routes to users#show immediately.
Started GET "/" for 192.168.0.4 at 2014-03-07 16:08:18 +0400
User Load (1.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Processing by UsersController#show as HTML
What am I doing wrong? Or is it simply does not work in rails 4.0.3?
The text was updated successfully, but these errors were encountered:
The first argument of authenticated is to match a specific scope, so authenticated :operator will only work for the Operator class and not User as you might be expecting (same thing goes for the :admin scope). I'm not sure, but maybe removing the symbol from the authenticated calls might provide the result you want.
I'm closing this since it does not seems to be a bug in Devise.
@lucasmazza, many thanks!
Removing symbol it not work for me, but if replace :operator and :admin to only :user it works perfectly!
Perhaps this method should be added to the documentation? I think I can do pull request, if needed.
Hello.
I trying redirect users to a root path based on their roles, using this method and based on this docs.
Then I go to root path, server always send me
users#show
.Moreover, log says that
has_role?
method not called, it routes tousers#show
immediately.What am I doing wrong? Or is it simply does not work in rails 4.0.3?
The text was updated successfully, but these errors were encountered: