jackdempsey / acts_as_commentable

The ActiveRecord acts_as_commentable plugin
http://juixe.com/svn/acts_as_commentable/
MIT License
834 stars 176 forks source link

CanCan ? #8

Closed TeuF closed 14 years ago

TeuF commented 14 years ago

Hi,

Someone know how to use cancan with acts_as_commentable ?

Thanks,

jackdempsey commented 14 years ago

TeuF,

Can you be more specific?

jack

TeuF commented 14 years ago

Ooohh just found it, sorry

And I tried this in my view:

  <% if can?(:create, Comment) %>
   ....
  <% end %>

instead of

  <% if can?(:create, @commentable.comments) %>
   ....
  <% end %>

Thanks

jackdempsey commented 14 years ago

Did that work for you? If you setup permissions in your app/models/ability.rb for who can and cannot create a Comment you should be ok. I'm not sure exactly what the question is here...

TeuF commented 14 years ago

Yes that's the question. But no it's still not working. Have you already used acts_as_commentable with cancan ? I want to restrict the creation of comments to some users.

jackdempsey commented 14 years ago

TeuF,

There's nothing about acts_as_commentable that should prevent you from using it with CanCan.

As long as you have a "can :create, Comment" in your ability.rb, and maybe some code making sure the user in Ability matches the user on a specific comment for :update purposes, you should be good. I'd read up more on CanCan if that doesn't quite make sense.