oh is very easy with cancan and the wiki has eveything you need

i recommend making the "is()" function that says the wiki

there are 2 easy ways to set a permission with cancan

one is the general way

if user.is(:guest) can :read, Article

this means that  gues user can read articles, all of them in general

the specific way is this


can :edit, Article do |article|
if article.owner == user
end

this means that user is allowed to edit if he is the owner

in case of your proyects you can do this

can :manage, Proyect do | proyect|
if proyect.user == current_user
end
if current_user.is(:guest) can :read, Proyect

or

if currenct.is(:guest) can :read, Proyect do | proyect|
if proyect.public == true
end





On Tue, Sep 14, 2010 at 3:19 PM, nobosh <bhellm...@gmail.com> wrote:

> Hi Marnen, thanks I think that's great. The question is now will
> CanCan Support that? Are you familiar with CanCan?
>
> Something like... (ability.rb)
>  def initialize(user)
>    user ||= User.new
>    if user.role? :super_admin
> .
> .
>  end
>
> user.rb
>        def role?(role)
>                return !!self.permission.find_by_name(role.to_s.camelize)
>        end
>
> ? That's the piece I can't put together.
>
> thxs!
>
>
> On Sep 14, 11:46 am, Marnen Laibow-Koser <li...@ruby-forum.com> wrote:
> > radhames brito wrote:
> > > role model is a gem that lets you add roles to the user as a method and
> > > saves the role into a field on the user table as a bitmask
> > > that is , lets say you have and array like this
> >
> > > ROLES = %w[admin moderator author banned]
> >
> > > this gord in your user model and you have a field in the user table
> > > called roles_mask
> >
> > [...]
> >
> > Wow, what a bad idea.  Remind me never to use that gem if that's really
> > the way it works.  Storing multiple values in one DB field (which is
> > essentially what the bitmask is doing) is generally not a good thing.
> >
> > Best,
> > --
> > Marnen Laibow-Koserhttp://www.marnen.org
> > mar...@marnen.org
> > --
> > Posted viahttp://www.ruby-forum.com/.
>
> --
> 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-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to