2012-05-03 6 views
0

내 결제 과정의 각 단계에서 PUT 요청을 통해 주문이 업데이트됩니다. 그러나 상태 중 하나는 GET (제어 할 수 없음)으로 업데이트 방법을 호출하여 내 사이트로 리디렉션되는 제 3 자에게 제출하는 양식이 있습니다.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 동사에 및 자원에 오류가 여부에 따라 다른 일을 것 같습니다. herehere을 참조하십시오.

다음 코드는 나를 위해 일한 :

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 
관련 문제