简体   繁体   中英

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.' } else format.html { render :new } end end end def edit @customer_details = CustomerDetail.find(params[:id]) end 
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.' } format.html { render 'edit', notice: 'customerDetails was successfully created.' }

Tried on my app and it works as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM