-
Notifications
You must be signed in to change notification settings - Fork 42
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
Deep transform_keys for inline associations #220
Comments
@trevorturk I came up with the following code: class AnotherUserResource
include Alba::Resource
transform_keys :lower_camel, cascade: true # <- `cascade` option
attributes :created_at
many :articles do
# transform_keys :lower_camel # This line is not required but works as if this line exists
attributes :user_id
end
end Here, |
That makes sense to me. I was thinking perhaps Thank you for your consideration to this! |
Today I was wondering if it would be worth making In any case, I don't mind whatever the solution is, and frankly the current functionality is fine, just some minor cruft when defining a resource. Anyway, thanks again! |
Making cascade default seems reasonable to me. Yes, it's a breaking change, so we need to offer a |
Is your feature request related to a problem? Please describe.
I'd like to have an option for
transform_keys
to work down through inline associations. Currently, you need to repeattransform_keys
within each association block.Additional context
Here's a code example based on the README which demonstrates the issue:
Note the commented-out
transform_keys
macro, which, when un-commented, results in the desired output. Here's an example from the console showing the difference:Ideally, I'd like to avoid repeating
transform_keys
for inline associations, but things do work as expected currently, so this is only a nice-to-have. I'm not sure if it would be convenient in Alba's code to make this possible, but I thought I'd mention it.Thank you!
The text was updated successfully, but these errors were encountered: