Monday, October 8, 2012

Re: [Rails] cancan

Thanks for the reply.

How cancan can be used for restricting the methods in controllers which has no models ?

On Friday, October 5, 2012 8:18:24 PM UTC+5:30, Walter Lee Davis wrote:

On Oct 5, 2012, at 7:46 AM, Avi wrote:

> Hello All,
>
> Does cancan works without fetching roles data from db?
> Can we give permissions accordingly?
> Can we configure those roles like enum classes in java or in any config file?

The default setup (all I've ever done) is to configure the various roles in the ability.rb class file. If you look at the documentation or the RailsCast, that's what they start with. As far as looking up the current user to determine what role that user has, CanCan assumes you're using some authentication, which probably means looking up the user from the database, and that the authentication creates a current_user method that returns an object representing that authenticated user. CanCan doesn't get into the business of creating that current_user, though.

Walter

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/0ctfzWMrvWUJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate