On Wed, May 18, 2011 at 11:52 AM, Kristian Mandrup <[email protected]> wrote:
> I'm curious whether you can define the :as option as a list of roles?
> All the examples I have seen only has the :as linked to the single
> role :admin.

In short, no, it's not a 'role' in the sense that you mean here,
rather the name of a parameter filter to use.  Your app itself will
need to have it's own logic and semantics for figuring out which
filter to use based on your own business rules.

> How would I use this with a roles system?
>
> Say I had a #current_user_roles method available from my Controller or
> whatever.
>
> def update
>  Project.update_attributes(params[:project], :as =>
> current_user_roles)
> end
>
> One possible DSL tweak allow something like this:
>
> as_role current_user_roles do |role|
>  role.update_attributes_of(Project).with params[:project]
>  role.create(Project).with params[:project]
> end
>
> Here the #as_role should return some object that has the methods
> #update_attributes #create and so on and a method/reader for the roles
> to apply the role permission check.
>
>
> On May 13, 2:00 am, Pan Thomakos <[email protected]> wrote:
>> Hi,
>>
>> I think it's awesome that Rails 3.1 introduces the attribute accessible
>> roles/permissions:
>>
>> class User
>>   attr_accessible :name, :as => :admin
>> end
>>
>> User.create(params[:user], :as => :admin)
>>
>> But would it be possible to make this a chained function as was done with
>> find, where and
>> scopes from Rails 2.x to Rails 3.0? Here's a little more on the
>> topic<http://ablogaboutcode.com/2011/05/12/activerecord-3-1-mass-assignment...>.
>> Maybe ARel could be
>> leveraged to do this?
>>
>> I can see that there might be conflicts with user defined scopes, but isn't
>> chaining functions
>> just so much more elegant than passing multiple hash parameters to a
>> function?
>>
>> Thanks,
>> Pan
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Core" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-core?hl=en.
>
>



-- 
Cheers

Koz

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to