Commit 4a40c500 by liyijie

Fix view path use model collection name

parent 1b884c7e
...@@ -35,7 +35,9 @@ class SimpleControllerGenerator < Rails::Generators::NamedBase ...@@ -35,7 +35,9 @@ class SimpleControllerGenerator < Rails::Generators::NamedBase
def view_path def view_path
return options.view if options.view.present? return options.view if options.view.present?
if controller_class_path.size > 1 if resource_collection.present?
resource_collection
elsif controller_class_path.size > 1
File.join controller_class_path[0], plural_name File.join controller_class_path[0], plural_name
else else
plural_name plural_name
...@@ -111,6 +113,10 @@ class SimpleControllerGenerator < Rails::Generators::NamedBase ...@@ -111,6 +113,10 @@ class SimpleControllerGenerator < Rails::Generators::NamedBase
resource_class&.model_name&.singular resource_class&.model_name&.singular
end end
def resource_collection
resource_class&.model_name&.collection
end
def attributes_names def attributes_names
begin begin
resource_class.columns.map(&:name) - %w(id created_at updated_at) resource_class.columns.map(&:name) - %w(id created_at updated_at)
......
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