Do I only prefix var names with @ i开发者_StackOverflow社区f I need that variable in a view?
Basically you want to use @variable_name (instance variables) when you want to access these variables outside of the local scope, one example is using them in the view.
Another example:
before_filter :setup
def index
# can access @profile
end
private
def setup
@profile = Profile.find(params[:profile_id])
end
精彩评论