0

I am using cancan with rails 4. My user model has many datings and a dating has many reply. In the user controller's show action, I want to authorize all of them:

@user = User.find params[:id]
authorize! :read, @user

@datings = @user.first_page_datings
authorize! :read, @datings

# How to authorize replies of all the datings here?

Question is how to authorize replies of all the datings here?

4

1 回答 1

1

与其尝试授权所有子对象,不如使用@dating = @user.datings.accessible_by(current_ability)加载允许的子对象。

于 2013-09-26T04:06:03.887 回答