2012-05-03 8 views
0

私のチェックアウトプロセスの各ステップで、注文はPUTリクエストによって更新されます。しかし、州の1つは、自分のサイトにリダイレクトする第三者に提出するフォームを持ち、GET(これを支配しない)で更新メソッドを呼び出します。GETリクエストでrespond_withの場所が無視される

私のrespond_withコードが完全に無視されているように見えますが、Missing Template checkout/updateというエラーが表示されるのはなぜですか?それは#editを打つべきです。

CheckoutController.rb

before_filter :load_order 

def update 
    if @order.update_attributes(params[:order]) 
    @order.next 
    end 
    respond_with(@order, :location => checkout_state_url(@order.state)) 
end 

routes.rbを

match '/checkout/update/:state' => 'checkout#update', :as => :update_checkout 
match '/checkout/:state' => 'checkout#edit', :as => :checkout_state 
match '/checkout' => 'checkout#edit', :state => 'client_details', :as => :checkout 

答えて

0

respond_withは、HTTP動詞時とリソースがエラーを持っているかどうかによって異なることを行いますように見えます。 hereおよびhereを参照してください。

次のコードは、私の仕事:

def update 
    if @order.update_attributes(params[:order]) && @order.next 
     respond_with(@order) { |format| format.html { redirect_to checkout_state_url(@order.state) } } 
    else 
     respond_with(@order) { |format| format.html { render :edit } } 
    end 
end 
関連する問題