Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 重定向_以进行编辑_Ruby On Rails_Ruby On Rails 3_Redirect_Controller_Routes - Fatal编程技术网

Ruby on rails 重定向_以进行编辑

Ruby on rails 重定向_以进行编辑,ruby-on-rails,ruby-on-rails-3,redirect,controller,routes,Ruby On Rails,Ruby On Rails 3,Redirect,Controller,Routes,我的应用程序中有一个很长的表单,所以我设置了一个\u new\u form.html.erb,它在我的new.html.erb中呈现。用户更新此表单并通过一些基本验证后,我希望将其重定向到呈现完整表单的编辑.html.erb,即\u new\u form.html.erb 我肯定这是基本的东西,但我不知道怎么做 我试着用下面的内容更新我的控球器中的创建操作,但现在我得到了答案 i、 e 您正试图重定向到编辑位置\u路径(:id)。符号:id不是您要在此处传递的。您想要位置的id或位置本身:red

我的应用程序中有一个很长的表单,所以我设置了一个
\u new\u form.html.erb
,它在我的
new.html.erb
中呈现。用户更新此表单并通过一些基本验证后,我希望将其重定向到呈现完整表单的
编辑.html.erb
,即
\u new\u form.html.erb

我肯定这是基本的东西,但我不知道怎么做

我试着用下面的内容更新我的控球器中的创建操作,但现在我得到了答案

i、 e


您正试图重定向到
编辑位置\u路径(:id)
。符号
:id
不是您要在此处传递的。您想要位置的id或位置本身:
redirect\u编辑位置路径(@location)

  def create
    @location = Location.new(params[:location])
      #redirect_to :action => "edit"

    respond_to do |format|
      if @location.save
        format.html { redirect_to edit_location_path(:id), notice: 'Location was successfully created.' }
        format.json { render json: @location, status: :created, location: @location }
      else
        format.html { render action: "new" }
        format.json { render json: @location.errors, status: :unprocessable_entity }
      end
    end
  end