Redirect_to edit

I have a rather long form in my application, so I set up _new_form.html.erb , which appears in my new.html.erb . After the user updates this form and carries out some basic checks, I would like them to be redirected to edit.html.erb , which displays the full form, i.e. _new_form.html.erb .

I am sure that this is the main material, but I can’t find out how to do it.

I tried updating the Create action in my Contoller with the below, but now I get.

i.e.

  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 
+6
source share
1 answer

You are trying to redirect to edit_location_path(:id) . Symbol :id is not what you want to convey here. You need a location id or its location: redirect_to edit_location_path(@location)

+13
source

All Articles