avo
avo copied to clipboard
Refresh page on association destroy
Context
The current behavior only reloads the association frame where an associated record is destroyed.
There are use cases where a whole page refresh is wanted, for example when some fields depend on the associations' records, like a counter.
Possible DSLs
-
field :posts, as: :has_many, refresh_on_destroy: true
-
field :posts, as: :has_many, on_destroy: :refresh
Workarounds
Override the destroy_success_action
on the association controller (Avo::Resources::Post
if you have the field :posts, as: :has_many
)
def destroy_success_action
flash[:notice] = destroy_success_message
respond_to do |format|
format.turbo_stream { render turbo_stream: turbo_stream.redirect_to(request.referer) }
end
end