2011-03-29 55 views

回答

6

基本上你想要在本地範圍之外訪問這些變量時使用@variable_name(實例變量),一個例子就是在視圖中使用它們。

又如:

before_filter :setup 

def index 
# can access @profile 
end 

private 

def setup 
    @profile = Profile.find(params[:profile_id]) 
end 
相關問題