Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
class <%= plural_table_name.camelize %>Controller < ApplicationController
def index
@list_of_<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all.order({ :created_at => :desc })
matching_<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all

@list_of_<%= plural_table_name.underscore %> = matching_<%= plural_table_name.underscore %>.order({ :created_at => :desc })
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't plural_table_name already underscored? I forget.

Copy link
Author

Choose a reason for hiding this comment

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

Just did a check, plural_table_name does not underscore.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a little inconsistent in draft_generators, but plural_table_name should already be underscored.

plural_table_name is just table_name.pluralize and table_name is underscored.

table_name

plural_table_name

Copy link
Author

Choose a reason for hiding this comment

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

That is interesting because when I was testing plural_table_name did not underscore, but it looks like in the docs it does say table_name is joining with "_". I wonder though because we do use plural_table_name throughout the generator with other methods such as .camelize, .humanize and title_case, would the auto underscoring be an issue underscoring for .camelize?

Copy link
Author

Choose a reason for hiding this comment

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

@jelaniwoods I moved our talk on table_name to a separate issue. With that being moved out, is this ready to ship?


render({ :template => "<%= plural_table_name.underscore %>/index.html.erb" })
end

def show
the_id = params.fetch("path_id")
@the_<%= singular_table_name.underscore %> = <%= class_name.singularize %>.where({ :id => the_id }).at(0)

matching_<%= plural_table_name.underscore.downcase %> = <%= class_name.singularize %>.where({ :id => the_id })

@the_<%= singular_table_name.underscore %> = matching_<%= plural_table_name.underscore.downcase %>.at(0)

render({ :template => "<%= plural_table_name.underscore %>/show.html.erb" })
end
Expand Down