在使用保存表单的参数提交表单时,rails重定向到编辑页面

时间:2016-07-30 06:50:51

标签: ruby-on-rails

我是rails的新手,我创建了一个customer_details表单。当我通过单击“保存”按钮提交表单时,应该保存并重定向到包含该表单所有内容的编辑页面。我可以使用下载按钮下载表单。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



 问题是,当我点击保存按钮时,它会重定向到编辑路径。但没有任何形式的内容。我现在应该怎么做才能在edit_path中获取表单?。某人plz帮助我。提前谢谢!!

1 个答案:

答案 0 :(得分:0)

试试这个format.html { render 'edit', notice: 'customerDetails was successfully created.' }

尝试使用我的应用,它按预期工作。