inossidabile / protector

Comfortable (seriously) white-list security restrictions for models on a field level
MIT License
270 stars 31 forks source link

can :create? with specific options #44

Open asiniy opened 10 years ago

asiniy commented 10 years ago

How to do that in protector?

I tried to do that, but with no luck.

if Contractor.restrict!(current_user).can(:create, :kind_cd: 1)
  # some view code here

I tried

      if user.contractors.any?{ |c| c.kind_cd == 1 }
        can :create, kind_cd: lambda { |k| k == 0 }
      else
        can :create
      end

and other, but there isn't any success :cry:

Do have protector any similar options?

inossidabile commented 10 years ago

I don't really understand what you are trying to achieve. Can you please explain what is your goal and not how you are trying to get there?

asiniy commented 10 years ago

I try to work with can? method.

How can I check that somebody can create something just with special options? (Like kind_cd = 1)

inossidabile commented 10 years ago

Oh. Protector is not currently available to do that. That would be nice to have such feature so I'll leave this open.

asiniy commented 10 years ago

ok.

I'll try to do that feature.