-
Notifications
You must be signed in to change notification settings - Fork 176
Open
Description
I have a nested resource in my application. It uses a model called Valuation, which renders multiple tabs. One of these tabs shows financial data (Valuation has_many Financials), and I added a custom destroy action for it.
I added this route:
routes do
delete :destroy, on: :member
end
Here’s my table:
tab :overwrites do
finances = instance.finances
table finances do
column :id
column :report
column 'Section / Sub Section' do |instance|
[instance&.section, instance&.sub_section].join('<br>').html_safe
end
column 'Group / Sub Group' do |instance|
[instance&.group, instance&.sub_group].join('<br>').html_safe
end
column :account
column :value
actions do |_toolbar, r, _a|
[
link_to(content_tag(:i, '', class: 'fas fa-trash'),
trestle.finances_admin_path(instance.uuid, f_id: r.id),
{ class: 'btn btn-danger',
data: { turbo_confirm: 'Please confirm delete.', turbo_method: :delete } })
].join(' ').html_safe
end
end
end
And this is my destroy action inside the controller:
def destroy
competitor = instance.finances.find(params[:f_id])
competitor.delete
flash[:message] = 'Overwrite was deleted successfully.'
redirect_to trestle.finances_admin_path(instance)
rescue StandardError => e
flash[:error] = e.message
redirect_to trestle.finances_admin_path(instance)
end
Is there a way to update the view without a full page refresh? Or at least refresh directly into the correct tab?
Because with redirect_to trestle.finances_admin_path(instance) I get redirected to the correct page, but it always loads the first tab.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels