Same instance variable for all actions of a controller
I have a rails controller with two actions defined: index and show . I have an instance variable defined in index action. The code is something like below: def index @some_instance_variable = foo end def show # some code end How can I access the @some_instance_variable in show.html.erb template? Unless you're rendering show.html.erb from the index action, you'll need to set @some_instance_variable in the show action as well. When a controller action is invoked, it calls the matching method -- so the contents of your index method will not be called when using the show action. If you need @some