3
뷰와 함께 인스턴스 변수를 올바르게 사용하는 방법을 모르겠다. 여기 누군가가 나를 계몽 할 수 있기를 바랍니다. 예를 들어 사용자가 목록에서 항목을 클릭 할 때Ruby on Rails - 부분 뷰가있는 인스턴스 변수의 범위
class MainController < ApplicationController
def index
@item_list = Item.find_all_item
end
def detail_display
@current_selected = @item= Item.find(params[:id])
redirect_to :action => :index
end
end
detail_display
가 호출됩니다. 변수 @current_selected
은 인덱스가 리디렉션 될 때 호출되는 부분보기 에 사용할 수 없습니다. 이 문제를 어떻게 해결할 수 있습니까?