Good morning, I have a problem saving my form_tag data, I think it may be a syntax error or ignorance since I'm new to Rails and web development, my problem is that I'm using my form_tag as follows : '
<%= form_tag(controller: "payrolls", action: "actualizar", method: "post", remote: true) do%>
When I give the submit it saves me the data but it also renders me the partial to update and I would not want it to do that, but if I do not believe the update.html.erb it throws me an error 204 because it can not find the template, it should be noted that in the update action I do not answer any, try with JS but it marks me error.
Thank you in advance for the help you can give me, regards.
Here is my update action:
def actualizar
payroll_params[:payroll].each do |upd_params|
params_employeewd= upd_params[:employee_wd_attributes]
params_payroll = {:employee_id=>upd_params[:employee_id], :week_id=>upd_params[:week_id], :department_id=>upd_params[:department_id], :dias_trabajados=>upd_params[:dias_trabajados],
:dias_vacaciones=>upd_params[:dias_vacaciones], :faltas=>upd_params[:faltas], :total_percepciones=>upd_params[:total_percepciones], :total_retenciones=>upd_params[:total_retenciones],
:total_sueldo_bruto=>upd_params[:total_sueldo_bruto], :total_sueldo_neto=>upd_params[:total_sueldo_neto], :sueldo_fiscal=>upd_params[:sueldo_fiscal], :pago_impuesto=>upd_params[:pago_impuesto],
:pago_eps=>upd_params[:pago_eps], :tipo_pago_fiscal=>upd_params[:tipo_pago_fiscal], :tipo_pago_eps=>upd_params[:tipo_pago_eps]}
@payroll = Payroll.find(upd_params[:id])
@payroll.update(params_payroll)
@employeewd = EmployeeWd.find(upd_params[:employee_wd_attributes][:id])
@employeewd.update(params_employeewd)
@employee_wad = EmployeeWad.all.where(payroll_id: upd_params[:id])
params_employeewad = upd_params[:employee_wad_attributes]
params_employeewad.each do |employeewad|
additional = employeewad[:id]
importe = employeewad[:importe_ads]
@employee_wad = EmployeeWad.find_by(payroll_id: upd_params[:id],additional_id: additional)
if importe == '0'
if @employee_wad
@employee_wad.destroy
end
else
if @employee_wad
@employee_wad.update({:importe_ads=>importe})
else
@employee_wad = EmployeeWad.create({:additional_id=>additional,:importe_ads=>importe, :payroll_id=>upd_params[:id]})
end
end
end
end
respond_to do |format|
format.js
end
end
I no longer mark error simply always redirect me to the template to update, which I do not want.