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

feat: support alias in matcher define_enum #1419

Merged
merged 1 commit into from Mar 4, 2021
Merged

feat: support alias in matcher define_enum #1419

merged 1 commit into from Mar 4, 2021

Conversation

brunohkbx
Copy link
Contributor

No description provided.

@wenderjean
Copy link

Do we have an issue related? :)

@brunohkbx
Copy link
Contributor Author

Do we need one? I ran into this when I was creating some aliases for a legacy table in a database.

@wenderjean
Copy link

It would be good to keep tracking and also describe what you're solving. It could be both a bugfix and a new feature.

@brunohkbx
Copy link
Contributor Author

Makes sense to me. @mcmire thoughts? I can describe it on an issue if you want.

@mcmire
Copy link
Collaborator

mcmire commented Feb 22, 2021

This is fine. I appreciate the updates to the documentation because I could figure out pretty quickly what this was about. No need for an issue :)

Copy link
Collaborator

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

One little thing, but this makes sense otherwise! I like how simple this PR is.

@@ -370,7 +376,10 @@ def expected_column_type
end

def column
model.columns_hash[attribute_name.to_s]
key = attribute_name.to_s
column_name = model.attribute_aliases[key] || key
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like attribute_aliases is not a public method in the API, but attribute_alias is: https://api.rubyonrails.org/classes/ActiveModel/AttributeMethods/ClassMethods.html#method-i-attribute_alias. What do you think about using that instead?

Copy link
Contributor Author

@brunohkbx brunohkbx Feb 22, 2021

Choose a reason for hiding this comment

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

I updated it. good catch! thanks

@brunohkbx
Copy link
Contributor Author

@mcmire would you mind reviewing it again? 😃

@mcmire
Copy link
Collaborator

mcmire commented Mar 4, 2021

Sorry for the delay. I was waiting until I had confirmation on the plan for the next version, but it seems like we've got that settled now. Looks good, merging now!

@mcmire mcmire merged commit c969f1d into thoughtbot:master Mar 4, 2021
@brunohkbx brunohkbx deleted the feat/support-alias-in-matcher-define_enum branch March 4, 2021 23:35
@vsppedro vsppedro mentioned this pull request Jun 4, 2021
@vsppedro vsppedro mentioned this pull request Jul 10, 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.

None yet

3 participants