Hari Prakash Hari Prakash - 5 months ago 14
Ruby Question

rails redirect to edit page when submitting the form with the params of saved form

I'm new to rails,I've created a customer_details form.when I submit a form by clicking save button It should be saved and redirected to the edit page with all the contents of the form.so that i can download the form using download button.This is what im getting after saved the form

def create
@customer_detail = CustomerDetail.new(customer_detail_params)
@customer_detail.company_profile_id = current_user.company_profile.id
respond_to do |format|
if @customer_detail.save
format.html { redirect_to edit_customer_detail_path(@customer_detail), notice: 'customerDetails was successfully created.' }
format.html { render :new }
def edit
@customer_details = CustomerDetail.find(params[:id])

problem is,when I click save button it redirects to the edit path.but without any contents of form. what should I do now to get the form in edit_path?.can someone plz help me.thanks in advance!!


Try this format.html { render 'edit', notice: 'customerDetails was successfully created.' }

Tried on my app and it works as expected.