Skip to content

Use rails convention to underscore collection class names#95

Merged
julianrubisch merged 1 commit into
stimulusreflex:masterfrom
rickychilcott:support-multi-word-collect-items
Apr 30, 2021
Merged

Use rails convention to underscore collection class names#95
julianrubisch merged 1 commit into
stimulusreflex:masterfrom
rickychilcott:support-multi-word-collect-items

Conversation

@rickychilcott
Copy link
Copy Markdown
Contributor

Bug Fix

Description

This would mean an object such as ActionItem when evaluated in a partial would show up as actionitem by default, instead of the expected action_item. Users of the library could override this with the as: option, such as as: :action_item in this case.

Prior to the change, this code would be need:

<!-- index.html.erb --!>
<%= futurize(collection: ActionItem.all, extends: :div)  { } %>

<!-- _action_item.html.erb --!>
<%= actionitem.description %>

Whereas, we would expect the following to work

<!-- index.html.erb --!>
<%= futurize(collection: ActionItem.all, extends: :div)  { } %>

<!-- _action_item.html.erb --!>
<%= action_item.description %>

Why should this be added

This follows Rails conventions and the principle of least surprise. However, this is a breaking change for users of this library, but is correct in following Rails conventions.

Checklist

  • My code follows the style guidelines of this project
  • Checks (StandardRB & Prettier-Standard) are passing

This would mean a class such as `ActionItem` when evaluated in a partial would show up as `actionitem` instead of the expected `action_item`. Users of the library could override this with the `as:` option.

Added extensive tests to ensure broadcast and `futurize` generator properly generate
Note this is a breaking change for users, but is correct in following rails conventions.
@rickychilcott
Copy link
Copy Markdown
Contributor Author

Sorry to bombard you @julianrubisch. Real-world use of this library is highlighting a few items for me.

@julianrubisch
Copy link
Copy Markdown
Contributor

Good catch, keep it coming!

Don't see an issue since we're targeting 1.0 anyway

@julianrubisch julianrubisch merged commit 1f7e1bb into stimulusreflex:master Apr 30, 2021
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.

2 participants