We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
I'm working on a project where Controllers and routes are namespaced but models are not.
This is how my scaffold are generated:
bundle exec rails g model Client first_name:string last_name:string bundle exec rails g scaffold_controller Admin::Client first_name:string last_name:string --model-name=Client
When specifying --model-name=Client, it would be great if the decorator wasn't namespaced and also not in a namespace folder, just like the model.
An easy fix would be editing this file: https://github.com/drapergem/draper/blob/master/lib/generators/rails/decorator_generator.rb and changing
def create_decorator_file template 'decorator.rb', File.join('app/decorators', class_path, "#{file_name}_decorator.rb") end
to
def create_decorator_file if parent_options[:model_name].present? template 'decorator.rb', File.join('app/decorators', "#{file_name}_decorator.rb") else template 'decorator.rb', File.join('app/decorators', class_path, "#{file_name}_decorator.rb") end end
and changing
https://github.com/drapergem/draper/blob/master/lib/generators/rails/templates/decorator.rb
<%- if parent_class_name.present? -%> class <%= class_name %>Decorator < <%= parent_class_name %> <%- else -%> class <%= class_name %> <%- end -%>
To not include ModuleName::ModelNameDecorator: class_name.split("::").last
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
I'm working on a project where Controllers and routes are namespaced but models are not.
This is how my scaffold are generated:
When specifying --model-name=Client, it would be great if the decorator wasn't namespaced and also not in a namespace folder, just like the model.
An easy fix would be editing this file: https://github.com/drapergem/draper/blob/master/lib/generators/rails/decorator_generator.rb
and changing
to
and changing
https://github.com/drapergem/draper/blob/master/lib/generators/rails/templates/decorator.rb
To not include ModuleName::ModelNameDecorator: class_name.split("::").last
The text was updated successfully, but these errors were encountered: