Skip to content

Conversation

@pmckernin
Copy link

I have edited the query style in the generator of the draft:resource controller. Going along the styling in card #91 I have changed our controller to appear in the same style. Please let me know what you think. In particular, about the spaces for the queries, this is how they appeared in the card, but I can easily remove them.

@pmckernin pmckernin self-assigned this Aug 10, 2020
@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?

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

matching_<%= class_name.singularize.downcase %> = <%= class_name.singularize %>.where({ :id => the_id })
Copy link
Contributor

@raghubetina raghubetina Aug 10, 2020

Choose a reason for hiding this comment

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

I think this should also be plural_table_name, for matching_whatevers?

Same for update, destroy.

Copy link
Author

Choose a reason for hiding this comment

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

Ok I cleaned up the plural table names

` the_id = params.fetch("path_id")

matching_rsvp_tables = RsvpTable.where({ :id => the_id })

@the_rsvp_table = matching_rsvp_tables.at(0)

@the_rsvp_table.group_id = params.fetch("query_group_id")`

@jelaniwoods
Copy link
Contributor

Generated a resource here.

LGTM

@raghubetina
Copy link
Contributor

LGTM!

in the summer 2020 quarter. This resolves #92
@pmckernin pmckernin force-pushed the pm-summer-2020-query-style branch from bba55d0 to 671e66b Compare August 11, 2020 22:19
@pmckernin pmckernin merged commit 671e66b into winter-2020 Aug 11, 2020
jelaniwoods pushed a commit that referenced this pull request Oct 22, 2022
in the summer 2020 quarter. This resolves #92
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.

4 participants