-
Notifications
You must be signed in to change notification settings - Fork 3
Disambiguating by breaking more conventions #3
New issue
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
eebc1c7
e8b006c
210d1c3
251fa4b
3d9b939
ee12f24
05abf80
01dcecb
9a205e3
5fb7865
ecd241a
0515e84
2a6a104
2b2e0ca
33ffdcf
a885da0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,9 @@ def generate_controller | |
| return if skip_controller? | ||
|
|
||
| if read_only? | ||
| template "controllers/read_only_controller.rb", "app/controllers/#{plural_table_name.underscore}_controller.rb" | ||
| template "controllers/read_only_controller.rb", "app/controllers/#{plural_table_name}_controller.rb" | ||
| else | ||
| template "controllers/controller.rb", "app/controllers/#{plural_table_name.underscore}_controller.rb" | ||
| template "controllers/controller.rb", "app/controllers/#{plural_table_name}_controller.rb" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [98/80] |
||
| end | ||
| end | ||
|
|
||
|
|
@@ -35,7 +35,7 @@ def generate_model | |
| def generate_view_files | ||
| available_views.each do |view| | ||
| filename = view_filename_with_extensions(view) | ||
| template filename, File.join("app/views", "#{plural_table_name}_templates", File.basename(filename)) | ||
| template filename, File.join("app/views", "#{singular_table_name}_templates", File.basename(filename)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [110/80] |
||
| end | ||
| end | ||
|
|
||
|
|
@@ -52,8 +52,8 @@ def generate_routes | |
| def generate_specs | ||
| return if read_only? || skip_controller? || skip_model? | ||
|
|
||
| template "specs/crud_spec.rb", "spec/features/crud_#{plural_table_name.underscore}_spec.rb" | ||
| template "specs/factories.rb", "spec/factories/#{plural_table_name.underscore}.rb" | ||
| template "specs/crud_spec.rb", "spec/features/crud_#{plural_table_name}_spec.rb" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [86/80] |
||
| template "specs/factories.rb", "spec/factories/#{plural_table_name}.rb" | ||
| end | ||
|
|
||
| private | ||
|
|
@@ -148,7 +148,7 @@ def available_views | |
| elsif skip_redirect? | ||
| %w(index show new_form create_row edit_form update_row destroy_row) | ||
| else | ||
| %w(index new_form edit_form show) | ||
| %w(index new_form new_form_with_errors edit_form show) | ||
| end | ||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,97 +1,106 @@ | ||
| class <%= plural_table_name.camelize %>Controller < ApplicationController | ||
| def index | ||
| @<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all | ||
| all_<%= plural_table_name %> = <%= class_name.singularize %>.all.order(:created_at => :desc) | ||
|
|
||
| render("<%= plural_table_name.underscore %>_templates/index.html.erb") | ||
| render("<%= singular_table_name %>_templates/index.html.erb", :locals => { | ||
| :list_of_<%= plural_table_name %> => all_<%= plural_table_name %> | ||
| }) | ||
| end | ||
|
|
||
| def show | ||
| @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id_to_display]) | ||
| <%= singular_table_name %>_to_show = <%= class_name.singularize %>.find(params["id_to_display"]) | ||
|
|
||
| render("<%= plural_table_name.underscore %>_templates/show.html.erb") | ||
| render("<%= singular_table_name %>_templates/show.html.erb", :locals => { | ||
| :the_<%= singular_table_name %> => <%= singular_table_name %>_to_show | ||
| }) | ||
| end | ||
|
|
||
| def new_form | ||
| <% unless skip_validation_alerts? -%> | ||
| @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.new | ||
| <% end -%> | ||
| render("<%= plural_table_name.underscore %>_templates/new_form.html.erb") | ||
| render("<%= singular_table_name %>_templates/new_form.html.erb") | ||
| end | ||
|
|
||
| def create_row | ||
| @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.new | ||
| <%= singular_table_name %>_to_add = <%= class_name.singularize %>.new | ||
|
|
||
| <% attributes.each do |attribute| -%> | ||
| @<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params[:<%= attribute.column_name %>] | ||
| <%= singular_table_name %>_to_add.<%= attribute.column_name %> = params["<%= attribute.column_name %>_from_form"] | ||
| <% end -%> | ||
|
|
||
| <% unless skip_validation_alerts? -%> | ||
| save_status = @<%= singular_table_name.underscore %>.save | ||
| save_status = <%= singular_table_name %>_to_add.save | ||
|
|
||
| if save_status == true | ||
| redirect_to("/<%= @plural_table_name.underscore %>", :notice => "<%= singular_table_name.humanize %> created successfully.") | ||
| redirect_to("/<%= plural_table_name %>", :notice => "<%= singular_table_name.humanize %> created successfully.") | ||
| else | ||
| render("<%= plural_table_name.underscore %>_templates/new_form.html.erb") | ||
| render("<%= singular_table_name %>_templates/new_form_with_errors.html.erb", :locals => { | ||
| :<%= singular_table_name %>_with_errors => <%= singular_table_name %>_to_add | ||
| }) | ||
| end | ||
| <% else -%> | ||
| @<%= singular_table_name.underscore %>.save | ||
| <%= singular_table_name %>_to_add.save | ||
|
|
||
| <% unless skip_redirect? -%> | ||
| redirect_to("/<%= @plural_table_name.underscore %>") | ||
| redirect_to("/<%= plural_table_name %>") | ||
| <% else -%> | ||
| @current_count = <%= class_name.singularize %>.count | ||
|
|
||
| render("<%= plural_table_name.underscore %>_templates/create_row.html.erb") | ||
| render("<%= singular_table_name %>_templates/create_row.html.erb", :locals => { | ||
| :current_count => <%= class_name.singularize %>.count | ||
| }) | ||
| <% end -%> | ||
| <% end -%> | ||
| end | ||
|
|
||
| def edit_form | ||
| @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:prefill_with_id]) | ||
| existing_<%= singular_table_name %> = <%= class_name.singularize %>.find(params["prefill_with_id"]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tIDENTIFIER |
||
|
|
||
| render("<%= plural_table_name.underscore %>_templates/edit_form.html.erb") | ||
| render("<%= singular_table_name %>_templates/edit_form.html.erb", :locals => { | ||
| :<%= singular_table_name %>_to_prefill => existing_<%= singular_table_name %> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tOP_ASGN |
||
| }) | ||
| end | ||
|
|
||
| def update_row | ||
| @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id_to_modify]) | ||
| <%= singular_table_name %>_to_change = <%= class_name.singularize %>.find(params["id_to_modify"]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tIDENTIFIER |
||
|
|
||
| <% attributes.each do |attribute| -%> | ||
| @<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params[:<%= attribute.column_name %>] | ||
| <%= singular_table_name %>_to_change.<%= attribute.column_name %> = params["<%= attribute.column_name %>_from_form"] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tIDENTIFIER |
||
| <% end -%> | ||
|
|
||
| <% unless skip_validation_alerts? -%> | ||
| save_status = @<%= singular_table_name.underscore %>.save | ||
| save_status = <%= singular_table_name %>_to_change.save | ||
|
|
||
| if save_status == true | ||
| redirect_to("/<%= @plural_table_name.underscore %>/#{@<%= singular_table_name.underscore %>.id}", :notice => "<%= singular_table_name.humanize %> updated successfully.") | ||
| redirect_to("/<%= plural_table_name %>/#{<%= singular_table_name %>_to_change.id}", :notice => "<%= singular_table_name.humanize %> updated successfully.") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tLT |
||
| else | ||
| render("<%= plural_table_name.underscore %>_templates/edit_form.html.erb") | ||
| render("<%= singular_table_name %>_templates/edit_form.html.erb", :locals => { | ||
| :<%= singular_table_name %>_to_prefill => <%= singular_table_name %>_to_change | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tOP_ASGN |
||
| }) | ||
| end | ||
| <% else -%> | ||
| @<%= singular_table_name.underscore %>.save | ||
| <%= singular_table_name %>_to_change.save | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tIDENTIFIER |
||
|
|
||
| <% unless skip_redirect? -%> | ||
| redirect_to("/<%= @plural_table_name.underscore %>/#{@<%= singular_table_name.underscore %>.id}") | ||
| redirect_to("/<%= plural_table_name %>/#{<%= singular_table_name %>_to_change.id}") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tLT |
||
| <% else -%> | ||
| render("<%= plural_table_name.underscore %>_templates/update_row.html.erb") | ||
| render("<%= singular_table_name %>_templates/update_row.html.erb", :locals => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tIDENTIFIER |
||
| :<%= singular_table_name %>_to_prefill => <%= singular_table_name %>_to_change | ||
| }) | ||
| <% end -%> | ||
| <% end -%> | ||
| end | ||
|
|
||
| def destroy_row | ||
| @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id_to_remove]) | ||
| <%= singular_table_name %>_to_delete = <%= class_name.singularize %>.find(params["id_to_remove"]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tIDENTIFIER |
||
|
|
||
| @<%= singular_table_name.underscore %>.destroy | ||
| <%= singular_table_name %>_to_delete.destroy | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tLT |
||
|
|
||
| <% unless skip_validation_alerts? -%> | ||
| redirect_to("/<%= @plural_table_name.underscore %>", :notice => "<%= singular_table_name.humanize %> deleted successfully.") | ||
| redirect_to("/<%= plural_table_name %>", :notice => "<%= singular_table_name.humanize %> deleted successfully.") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tIDENTIFIER |
||
| <% else -%> | ||
| <% unless skip_redirect? -%> | ||
| redirect_to("/<%= @plural_table_name.underscore %>") | ||
| redirect_to("/<%= plural_table_name %>") | ||
| <% else -%> | ||
| @remaining_count = <%= class_name.singularize %>.count | ||
|
|
||
| render("<%= plural_table_name.underscore %>_templates/destroy_row.html.erb") | ||
| render("<%= singular_table_name %>_templates/destroy_row.html.erb", :locals => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tIDENTIFIER |
||
| :remaining_count => <%= class_name.singularize %>.count | ||
| }) | ||
| <% end -%> | ||
| <% end -%> | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,17 @@ | ||
| class <%= plural_table_name.camelize %>Controller < ApplicationController | ||
| def index | ||
| @<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all | ||
| all_<%= plural_table_name %> = <%= class_name.singularize %>.all.order(:created_at => :desc) | ||
|
|
||
| render("<%= plural_table_name %>_templates/index.html.erb", :locals => { | ||
| :list_of_<%= plural_table_name %> => all_<%= plural_table_name %> | ||
| }) | ||
| end | ||
|
|
||
| def show | ||
| @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id]) | ||
| <%= singular_table_name %>_to_show = <%= class_name.singularize %>.find(params[:id_to_display]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tIDENTIFIER |
||
|
|
||
| render("<%= plural_table_name %>_templates/show.html.erb", :locals => { | ||
| :the_<%= singular_table_name %> => <%= singular_table_name %>_to_show | ||
| }) | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [108/80]