I am using authlogic as a authentication engine in my rails app. I have two types of users 1) Users who are registered and has access to there own profile. 2) Admin user who has access to everybody''s profile In the user table i have a :is_admin field boolean field which defines the admin user. like the current_user method, Is there a way authlogic provides which can tell me if the current user is admin? Any help appreciated.. - S -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 15 July 2010 13:33, Sachin <sachinmayurjoshi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am using authlogic as a authentication engine in my rails app. > I have two types of users 1) Users who are registered and has access > to there own profile. > 2) Admin user who has access to everybody''s profile > > In the user table i have a :is_admin field boolean field which defines > the admin user. > > like the current_user method, Is there a way authlogic provides which > can tell me if the current user is admin?Perhaps I am missing something but I would have thought that current_user.is_admin would have done what you want. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Colin, In the mean i tried a bit and wrote a method named "admin_user" referring to the "current_user" method in application controller. def current_user return @current_user_session if defined?(@current_user) @current_user = current_user_session && current_user_session.record end def admin_user return @current_user.is_admin? end Now i am checking both the conditions if current_user && admin_user do bla bla ... end now it started the working the way i want. Cheers - S On Jul 15, 5:45 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 15 July 2010 13:33, Sachin <sachinmayurjo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I am using authlogic as a authentication engine in my rails app. > > I have two types of users 1) Users who are registered and has access > > to there own profile. > > 2) Admin user who has access to everybody''s profile > > > In the user table i have a :is_admin field boolean field which defines > > the admin user. > > > like the current_user method, Is there a way authlogic provides which > > can tell me if the current user is admin? > > Perhaps I am missing something but I would have thought that > current_user.is_admin > would have done what you want. > > Colin-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.