Commit 41049583 by liyijie

Add resource class support more than 3 modules

parent 4a40c500
......@@ -80,12 +80,15 @@ class SimpleControllerGenerator < Rails::Generators::NamedBase
# Second priority is the top namespace model, e.g. EngineName::Article for EngineName::Admin::ArticlesController
@resource_class ||= begin
namespaced_classes = controller_class_name.split('::')
namespaced_class = [namespaced_classes.first, namespaced_classes.last].join('::').singularize
namespaced_classes.delete_at(1)
namespaced_class = namespaced_classes.join('::').singularize
namespaced_class.constantize
rescue NameError
nil
end
# Third priority the camelcased c, i.e. UserGroup
@resource_class ||= begin
camelcased_class = controller_class_name.singularize
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment