adding :name option to load_and_authorize_resource if it does not match controller - closes #65

This commit is contained in:
Ryan Bates
2010-05-21 14:20:45 -07:00
parent dfd84a10ed
commit 2a3dd85a18
4 changed files with 20 additions and 1 deletions

View File

@@ -59,6 +59,11 @@ module CanCan
#
# load_resource :nested => [:publisher, :author]
#
# [:+name+]
# The name of the resource if it cannot be determined from controller (string or symbol).
#
# load_resource :name => :article
#
# [:+resource+]
# The class to use for the model (string or constant).
#
@@ -102,6 +107,11 @@ module CanCan
# [:+except+]
# Does not apply before filter to given actions.
#
# [:+name+]
# The name of the resource if it cannot be determined from controller (string or symbol).
#
# load_resource :name => :article
#
# [:+resource+]
# The class to use for the model (string or constant). Alternatively pass a symbol
# to represent a resource which does not have a class.

View File

@@ -54,7 +54,7 @@ module CanCan
end
def model_name
@params[:controller].sub("Controller", "").underscore.split('/').last.singularize
@options[:name] || @params[:controller].sub("Controller", "").underscore.split('/').last.singularize
end
def collection_actions