avo icon indicating copy to clipboard operation
avo copied to clipboard

`belongs_to` doesn't get the record value on action

Open Paul-Bob opened this issue 1 year ago • 2 comments

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.

actions_belongs

Paul-Bob avatar Jan 18 '24 09:01 Paul-Bob

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?

adrianthedev avatar Jan 18 '24 09:01 adrianthedev

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
}

Paul-Bob avatar Jan 18 '24 16:01 Paul-Bob