Skip to content

Conversation

@raghubetina
Copy link
Contributor

  • Removing all instance variables to decouple variable name choices
    between actions that re-use templates, and to remove the additional
    cognitive load of learning what an instance variable is. Also,
    avoiding state is better practice anyway, IMO.
  • Using strings as keys to the params hash following the heuristic:
    "If we could change it to 'zebra' on a whim, then use a string;
    otherwise use a symbol."
  • Making variable and input names longer and more pedantic.

<%= singular_table_name %>_to_show = <%= class_name.singularize %>.find(params[:id_to_display])

render("<%= plural_table_name.underscore %>_templates/show.html.erb", :locals => {
:the_<%= singular_table_name.underscore %> => <%= singular_table_name %>_to_show

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tLT
unterminated string meets end of file


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])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER

class <%= plural_table_name.camelize %>Controller < ApplicationController
def index
@<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all
all_<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all.order(:created_at => :desc)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER

@remaining_count = <%= class_name.singularize %>.count
render("<%= plural_table_name.underscore %>_templates/destroy_row.html.erb")
render("<%= singular_table_name.underscore %>_templates/destroy_row.html.erb", :locals => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER
unterminated string meets end of file

<% unless skip_validation_alerts? -%>
redirect_to("/<%= @plural_table_name.underscore %>", :notice => "<%= singular_table_name.humanize %> deleted successfully.")
redirect_to("/<%= plural_table_name.underscore %>", :notice => "<%= singular_table_name.humanize %> deleted successfully.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER
unexpected token tRPAREN


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.underscore %>/#{<%= singular_table_name.underscore %>_to_change.id}", :notice => "<%= singular_table_name.humanize %> updated successfully.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tLT
unexpected token tRPAREN


<% attributes.each do |attribute| -%>
@<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params[:<%= attribute.column_name %>]
<%= singular_table_name.underscore %>_to_change.<%= attribute.column_name %> = params["form_<%= attribute.column_name %>"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER
unexpected token tOP_ASGN


def update_row
@<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id_to_modify])
<%= singular_table_name.underscore %>_to_change = <%= class_name.singularize %>.find(params["id_to_modify"])

Choose a reason for hiding this comment

The 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.underscore %>_templates/edit_form.html.erb", :locals => {
:<%= singular_table_name.underscore %>_to_prefill => existing_<%= singular_table_name.underscore %>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tOP_ASGN
unexpected token tIDENTIFIER


def edit_form
@<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:prefill_with_id])
existing_<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params["prefill_with_id"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER

 - Removing all instance variables to decouple variable name choices
   between actions that re-use templates, and to remove the additional
   cognitive load of learning what an instance variable is. Also,
   avoiding state is better practice anyway, IMO.
 - Using strings as keys to the `params` hash following the heuristic:
   "If we could change it to 'zebra' on a whim, then use a string;
   otherwise use a symbol."
 - Making variable and input names longer and more pedantic.
@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 => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER
unterminated string meets end of file

<% 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.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER
unexpected token tRPAREN

<%= singular_table_name %>_to_delete = <%= class_name.singularize %>.find(params["id_to_remove"])
@<%= singular_table_name.underscore %>.destroy
<%= singular_table_name %>_to_delete.destroy

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tLT

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"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER

redirect_to("/<%= plural_table_name %>/#{<%= singular_table_name %>_to_change.id}")
<% else -%>
render("<%= plural_table_name.underscore %>_templates/update_row.html.erb")
render("<%= singular_table_name %>_templates/update_row.html.erb", :locals => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER
unexpected token tLCURLY


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.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tLT
unexpected token tRPAREN


<% 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"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER
unexpected token tOP_ASGN


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"])

Choose a reason for hiding this comment

The 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 %>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tOP_ASGN
unexpected token tIDENTIFIER


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"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER

@<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id])
id_of_<%= singular_table_name %>_to_show = params.fetch("id_to_display")

@<%= singular_table_name %>_to_show = <%= class_name.singularize %>.find(id_of_<%= singular_table_name %>_to_show)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected @'


def show
@<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id])
id_of_<%= singular_table_name %>_to_show = params.fetch("id_to_display")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER

id_of_<%= singular_table_name %>_to_show = params.fetch("id_to_display")

render("<%= plural_table_name.underscore %>_templates/show.html.erb")
@<%= singular_table_name %>_to_show = <%= class_name.singularize %>.find(id_of_<%= singular_table_name %>_to_show)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected @'


def show
@<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id_to_display])
id_of_<%= singular_table_name %>_to_show = params.fetch("id_to_display")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER

class <%= plural_table_name.camelize %>Controller < ApplicationController
def index
@<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all
@list_of_<%= plural_table_name %> = <%= class_name.singularize %>.all.order({ :created_at => :desc })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER

%w(index show new_form create_row edit_form update_row destroy_row)
else
%w(index new_form edit_form show)
%w(index show new_form new_form_with_errors edit_form edit_form_with_errors)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [84/80]


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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [86/80]

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))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [110/80]

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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [98/80]


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"

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]

murugan-r added a commit that referenced this pull request Jun 20, 2018
* Add github login

* #3 - Fixed failing test

* #3 - Fixed other test cases

* #3 - Minor changes

* #3 - Indentation fixes

* #3 Added .rubocop.yml and fixed rubocop issues

* #3 - Test cases for https://github.com/firstdraft/ideas/pull/3

* #3 - CicleCi add minitest_globs  and fixed rubocop issues

* #3 - Added bootswatch paper theme

* #3 - Turn off hound ci for js, css

* we do not recommend using capybara

* added database yml to gitignore

* added database yml sample file for postgresqlapp

* #3 - Removed rspec completely

* #3 - Remove Factory Girl and instead uses fixtures

* #3 - Updated CircleCi.yml and modified setup script

* #3 - Added database.yml.ci

* #3 - Review comments changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants