making accessible_by action default to :index and parent action default to :show so we don't check :read action directly - closes #302

This commit is contained in:
Ryan Bates
2011-03-15 23:00:40 -07:00
parent 3639ca90eb
commit fdd5ad022d
3 changed files with 6 additions and 6 deletions

View File

@@ -105,7 +105,7 @@ module CanCan
end
def authorization_action
parent? ? :read : @params[:action].to_sym
parent? ? :show : @params[:action].to_sym
end
def id_param

View File

@@ -4,7 +4,7 @@ module CanCan
module ModelAdditions
module ClassMethods
# Returns a scope which fetches only the records that the passed ability
# can perform a given action on. The action defaults to :read. This
# can perform a given action on. The action defaults to :index. This
# is usually called from a controller and passed the +current_ability+.
#
# @articles = Article.accessible_by(current_ability)
@@ -19,7 +19,7 @@ module CanCan
# @articles = Article.accessible_by(current_ability, :update)
#
# Here only the articles which the user can update are returned.
def accessible_by(ability, action = :read)
def accessible_by(ability, action = :index)
ability.model_adapter(self, action).database_records
end
end