Skip to content
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

Use the helper context methods or constructing action routes #2595

Merged
merged 1 commit into from
Dec 14, 2021

Conversation

cbeer
Copy link
Member

@cbeer cbeer commented Dec 11, 2021

No description provided.

@cbeer cbeer force-pushed the action-helper-routes branch 2 times, most recently from 50e78e8 to 5f9e131 Compare December 11, 2021 17:24
@jcoyne
Copy link
Member

jcoyne commented Dec 11, 2021

Can you explain why we need this change? Doesn't view_components already include the routes? https://github.com/github/view_component/blob/8d284a08a963fe3c5e7587da73f5d9906c7e7937/lib/view_component/base.rb#L370

@cbeer
Copy link
Member Author

cbeer commented Dec 11, 2021

@jcoyne
Copy link
Member

jcoyne commented Dec 12, 2021

Can you drop that in a comment so we don't accidentally factor it out later?

elsif url_opts[:id].class.respond_to?(:model_name)
url_for([@action.key.to_sym, url_opts[:id]])
helpers.url_for([@action.key.to_sym, url_opts[:id]])
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to delegate to helpers?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes? At least for now, until we sort out a better way for plugins like blacklight-marc (above) to do its thing.

else
public_send("#{@action.key}_#{controller_name}_path", url_opts)
helpers.public_send("#{@action.key}_#{helpers.controller_name}_path", url_opts)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need helpers.controller_name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely. There's no such method in scope here.

@jcoyne jcoyne merged commit f11500d into main Dec 14, 2021
@jcoyne jcoyne deleted the action-helper-routes branch December 14, 2021 16:38
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.

None yet

2 participants