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

Map attribute aliases to column names when initializing #95

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joelvh
Copy link

@joelvh joelvh commented Apr 16, 2021

@joelvh
Copy link
Author

joelvh commented Apr 17, 2021

@seuros @rafaelfranca there seem to be some job errors (not test failures) - can you re-run the jobs?

@seuros
Copy link
Member

seuros commented Apr 17, 2021

@joelvh can you rebase/merge master to this branch ?

@seuros seuros self-assigned this Apr 17, 2021
@seuros
Copy link
Member

seuros commented Apr 17, 2021

@joelvh I think alias_attribute should be in active-model

cc @rafaelfranca

@joelvh
Copy link
Author

joelvh commented Apr 18, 2021

@seuros do you have a suggestion of how to accomplish this in ActiveModel? Using Pry, I didn't see any calls from the constructor handling the attributes using ActiveModel, from what I recall because I also thought it might fit there. The place to implement this in AR was much clearer.

@joelvh
Copy link
Author

joelvh commented Apr 18, 2021

@seuros I've come up with a fix for ActiveModel in state-machines/state_machines-activemodel#28. However, my tests to see if ActiveRecord is fixed by this indicate the params handled by ActiveModel don't get passed to ActiveRecord.

I'm doing some investigating, but it would appear my previous comment still stands, that AR either doesn't use the AM initialization or the transformed params are not passed along properly.

@joelvh
Copy link
Author

joelvh commented Apr 18, 2021

@seuros my latest investigation points to define_state_initializer defined in ActiveRecord and ActiveModel implementations, but they don't inherit from each other. Is that a correct observation? That would explain what I saw using pry and why the AR implementation is not fixed by this PR alone.

It would seem that we need separate fixes (e.g. the two PRs I've created) unless there's a way to to have AR's initializer trigger AM's inside the state machine.

@joelvh joelvh force-pushed the feature/initialize_with_attribute_aliases branch from bb1ab2a to bfa9d17 Compare April 18, 2021 19:43
@joelvh joelvh force-pushed the feature/initialize_with_attribute_aliases branch from bfa9d17 to 0e32ee4 Compare April 26, 2021 17:55
@joelvh
Copy link
Author

joelvh commented Apr 26, 2021

@seuros I've rebased this

@joelvh
Copy link
Author

joelvh commented May 10, 2021

@seuros just checking to see if this is the route to go or the ActiveModel PR.

@joelvh
Copy link
Author

joelvh commented Aug 23, 2021

@seuros will this be merged?

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