2011-03-17 2 views
0

Rails 2.3.8 사용.Rails에서 리디렉션 URL 수정

나는 이것을 내 컨트롤러에 가지고 있습니다.

def destroy 
    @shop = Shop.find(params[:id]) 
    @shop.destroy 
    flash[:notice] = 'Successfully deleted ' + @shop.shop_type.singularize + '.' 
    redirect_to shops_path(@shop.shop_type) 
    end 

내가 가게를 삭제할 때마다

, 나는 그것이 적절한 shop_type로 리디렉션합니다. 대신 정확한 URL의

http://localhost:3000/shops.places 

: 그것은 저를 리디렉션

http://localhost:3000/shops?type=places 

내가 올바른 URL로 리디렉션하기 위해 무엇을 할 수 있는가?

감사합니다.

답변

4

다음을 시도해보십시오. redirect_to line을 변경했습니다.

def destroy 
    @shop = Shop.find(params[:id]) 
    @shop.destroy 
    flash[:notice] = 'Successfully deleted ' + @shop.shop_type.singularize + '.' 
    redirect_to shops_path(:type => @shop.shop_type) 
end 
+0

멋진. 감사. – Victor