2013-04-02 8 views
6

私は_new_form.html.erbを私のnew.html.erbにレンダリングされるように設定しました。ユーザーがこのフォームを更新し、いくつかの基本的な検証をパスした後、_new_form.html.erbというフルフォームを表示するedit.html.erbにリダイレクトさせていただきたいと思います。redirect_to編集

これは基本的なものだと確信していますが、それを行う方法がわかりません。

私のContollerでアクションを作成しましたが、ここではここで取り組んでいます。

すなわち

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 

答えて

13

あなたはedit_location_path(:id)にリダイレクトしようとしています。 :idのシンボルはあなたがここに渡したいものではありません。場所のIDまたは場所自体が必要です。redirect_to edit_location_path(@location)

+0

賢い、ありがとうございます。 – Holly