我正在关注 Ryan Bates 的声明性授权railscast。我正在尝试为特定文章的作者添加功能,以便能够编辑他文章中留下的评论,无论他是否是所有者。我试过这样做,但无法让它工作。
role :author do
has_permission_on :articles, :to => [:new, :create]
has_permission_on :articles, :to => [:edit, :update, :show] do
if_attribute :user => is { user }
end
**has_permission_on :comments, :to => [:edit, :update] do
if_attribute :article_id => is { user }
end**
end
我如何修改评论行上的 has_permission 以允许用户编辑评论,如果他们只留在他的文章中?
谢谢