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