Re: Login controller additions: SOLUTION

Tobias Luetke
Thu, 10 Mar 2005 20:00:43 -0000

I actually use very similar code in snowdevil.

But i wrapped it in a model method and access it as
user.role?("admin")


On Thu, 10 Mar 2005 18:25:11 +0200, Jarkko Laine
<jarkko-k1O+Gnc6WpmsTnJN9+BGXg@public.gmane.org>
wrote:
>
> On 10.3.2005, at 18:17, Jonas Montonen wrote:
> >
> >  Well... after som testing my solution did not work after all... but
> > Jarkko''s did.
> >  Great!
> >
> >  @session[''user''].roles.collect{ |role| role.id
}.include?(1)
>
> The reason is that the roles array consists of role objects, not
id''s.
> It might still work if Role objects had a to_int method that would
> return their id, but I don''t know if that''s the case.
>
> //jarkko
>
> --
> Jarkko Laine
> http://jlaine.net
> http://odesign.fi
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
>


--
Tobi
http://www.snowdevil.ca - Snowboards that don''t suck
http://www.hieraki.org   - Open source book authoring
http://blog.leetsoft.com - Technical weblog