2011-07-29 5 views
1

어떻게 리디렉션을 사용하고 개체를 편집 작업에 전달합니까? 다음 코드는 작동하지 않습니다어떻게 리디렉션을 사용하고 개체를 편집 작업에 전달합니까?

def edit 
    @promotion = Promotion.find_by_id(@params['promo_id']) 
    end 

    def update 
    promotion = Promotion.find(params[:promotion_profile][:promotion_id]) 
     promo_perfil = promotion.profile 

     if promo_perfil.update_attributes(params[:promotion_profile]) 

     redirect_to admin_edit_path(promotion.id => @params[:promo_id]) 
     else 
    end 
+0

어떻게 든 같은 질문을 던졌습니다. http://stackoverflow.com/questions/6865452/how-do-you-use-redirect-to-when-the-action-is-dependent-on-a-parameter 너는 내 대답을 받아들이거나 코멘트를 기다리고있다. – apneadiving

답변

3

편집 작업은 params['promo_id']를 찾고 있습니다 (이유 @params['promo_id']?).

redirect_to admin_edit_path(:promo_id => promotion) 
1

당신은 다만이 경우 리디렉션 안 :이 표준 레일 행동, 당신의 방법으로 모든 스캐 폴딩 컨트롤러에이를 볼 수있다 render :action => :edit

그래서 :promo_id 이런 식으로 통과 편집 객체를 채우기 위해 쿠키에 객체를 의존하지 않고도 업데이트 액션에서 현재 객체로 편집 폼을 다시 렌더링 할 수 있습니다.

관련 문제