Hello, i have a rails app that use turbo_rails to render and submit some forms, the error is when i submit that form and try to redirect the target page doesnt load, i add 'data-turbo': false property to the submission button and the page is redirected when the record is saved but when the record is invalid, the page go to the render page that should be in the modal only
def create
@payment = @payments.new({ **pago_params, estado: Pago::TO_VERIFY })
@accounting = Invoice::BuildAccountingService.new(@invoice).call!
@accounts = BankAccount.active.select(:id, :name)
respond_to do |format|
if @payment.save
@invoice.update!(estado: Facturacion.statuses[:pending]) if @payment.monto <= @accounting[:balance]
format.html { redirect_to super_admin_factura_path(@invoice) }
else
format.html { render :new, status: :unprocessable_entity }
end
end
end
= turbo_frame_tag 'invoice_details' do
.columns.is-gapless.mt-4.mb-0
%h1.title.column= "Periodo: #{get_invoice_period(invoice)}"
%h1.title.has-text-right.column= invoice.estado
%p.title.is-5
= company.razon_social
%br
= company.direccion
%hr/
%table.table.is-fullwidth.is-bordered
%thead
%th Plan
%th Precio
%th Cantidad
%th Total
%tbody
%tr
%td= invoice.nombre_plan
%td= invoice.precio_plan.format
%td= get_sended_sms(accounting)
%td= invoice.precio_plan.format
%tr
%td SMS Adicionales
%td= invoice.precio_sms_adicional.format
%td= accounting[:additional_sms]
%td= accounting[:additional_sms_cost].format
%tr
%th{colspan: 3, class: 'has-text-right'} TOTAL:
%td= accounting[:total_cost]
%p.title.is-4
Pagos
- has_payments = payments.exists?
%table.table.is-fullwidth.is-bordered.is-hoverable
%thead
%tr
%th Banco
%th Referencia
%th Estado
%th Monto
%tbody
- unless has_payments
%tr
%th{ colspan: 4, class: 'has-text-centered' } No se han realizado pagos
- payments.each do |payment|
%tr
%td= payment.tipo_de_pago
%td= payment.referencia
%td= payment.estado
%td= payment.monto.format
%tr
%th{ colspan: 3, class: 'has-text-right' } TOTAL:
%td= payments.sum(&:monto)
.title.is-4.has-text-right
Balance:
%span{ class: "#{accounting[:balance].positive? ? 'has-text-danger' : 'has-text-success'}" }
= accounting[:balance]
- if accounting[:balance].positive? && has_payments
.has-text-centered.mb-3
= link_to 'Revisar pagos', payment_paths[:index], class: 'button is-primary'
- if accounting[:balance].positive?
.has-text-centered.mb-3
= link_to 'Agregar pago', payment_paths[:new], class: 'button is-primary', data: { turbo_frame: 'new_payment' }
= turbo_frame_tag 'new_payment'
= turbo_frame_tag 'new_payment' do
= render 'shared/common/modal', title: "Agregar pago a la factura ##{@invoice.id}" do
= render partial: 'shared/errors', locals: { resource: @payment }
= render partial: 'shared/errors', locals: { resource: @invoice }
= form_with model: @payment, url: super_admin_factura_pagos_path(@invoice), local: true do |f|
.field
= f.label :bank_account_id, "Metodo de Pago", class: 'label', for: 'bannk_account_id'
.control
%p.select.is-fullwidth
= f.select :bank_account_id, options_from_collection_for_select(@accounts, :id, :name, params[:bank_account_id]),
prompt: 'Selecione su metodo de pago'
.field
= f.label :referencia, "Referencia del pago", class: 'label', for: 'referencia'
.control
= f.text_field :referencia, class: 'input', id: 'referencia'
.field
= f.label :monto, "Monto del pago", class: 'label', for: 'monto'
.control
= f.number_field :monto, value: @accounting[:balance].to_i, class: 'input', id: 'monto'
.field.mb-3
= f.submit "Agregar", class: "button is-success", 'data-turbo': false
.modal.is-active{ data: { controller: 'modal' } }
.modal-background
.modal-card.my-5{ style: 'width: 80%; max-width: 80%;' }
.modal-card-head
%p.modal-card-title= title
%a.delete{ data: { action: 'click->modal#hide' }, aria: { label: 'close' }}
.modal-card-body
= yield
Hello, i have a rails app that use
turbo_railsto render and submit some forms, the error is when i submit that form and try to redirect the target page doesnt load, i add'data-turbo': falseproperty to the submission button and the page is redirected when the record is saved but when the record is invalid, the page go to therenderpage that should be in the modal onlyPOSTmethod