首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >redirect_to编辑

redirect_to编辑
EN

Stack Overflow用户
提问于 2013-04-02 02:08:47
回答 1查看 10.5K关注 0票数 8

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

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

我已经尝试过用下面的内容更新Contoller中的Create操作,但现在我已经做到了。

代码语言:javascript
复制
  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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-02 02:12:38

您正在尝试重定向到edit_location_path(:id)。符号:id不是您想在这里传递的。您想要位置的id或位置本身:redirect_to edit_location_path(@location)

票数 15
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15754919

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档