Added support for engines and namespaced models.

This commit is contained in:
Steven Anderson
2011-07-20 09:31:53 +01:00
parent 600a3e16a5
commit 6c497b8dd9
2 changed files with 19 additions and 1 deletions
+7 -1
View File
@@ -134,7 +134,7 @@ module CanCan
def resource_class
case @options[:class]
when false then name.to_sym
when nil then name.to_s.camelize.constantize
when nil then namespaced_name.to_s.camelize.constantize
when String then @options[:class].constantize
else @options[:class]
end
@@ -203,6 +203,12 @@ module CanCan
@name || name_from_controller
end
def namespaced_name
@params[:controller].sub("Controller", "").singularize.constantize
rescue NameError
name
end
def name_from_controller
@params[:controller].sub("Controller", "").underscore.split('/').last.singularize
end