avo
avo copied to clipboard
`belongs_to` doesn't get the record value on action
Describe the bug
From here -> https://discord.com/channels/740892036978442260/1197438245026418759
When running an action from record's show view, text field get the value from record but belongs_to don't.
Let's not work on this yet and think about a permanent solution for the "hydrate from record" situation.
I'm thinking about a new option hydrate_from: :record
or something that will use that in case they want to use that.
Otherwise, the hydration will stay flat for every action field.
It's a breaking change for current users but I think it's the best way to fix this.
WDYT?
Totally agree, we already had this discussion over some issues and discord threads and for some folks do not make sense to hydrate the values from the record. I totally get both sides so hydrate_from
option would improve both experiences.
Maybe to avoid a breaking change we can do a true
/ false
flag where the default flag value preserve the previous behavior and can be deactivated by changing the flag to false
, ex:
self.hydrate_from_record = false # default here is true
OR
self.hydration = {
active: -> { true / false / user.admin? / params[:active_hydration] / etc... }, # default here is true
from: -> { record / resource / Model.find(53) / etc... } # default here is record
}