# Visibility controller instance variables

**URL:** <https://www.ruby-forum.com/t/visibility-controller-instance-variables/111457>\
**Category:** Rails\
**Created:** [August 7, 2007, 3:25pm UTC](https://www.ruby-forum.com/t/visibility-controller-instance-variables/111457 "2007-08-07T15:25:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [August 7, 2007, 3:25pm UTC](https://www.ruby-forum.com/t/visibility-controller-instance-variables/111457/1 "2007-08-07T15:25:02Z")

</div>

Hi all,

class SomethingController \< ApplicationController

def action1  
@instance\_var = SomeClass.find(1)  
end

def action2  
#…  
end

end

It seems I have to assign @instance\_var as well in action2, even I run  
through action1 earlier?  
If I don’t assign it, @instance\_var is nil in action2.rhtml.

Is my assumption correct or do I miss something?

Vince

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [August 7, 2007, 5:30pm UTC](https://www.ruby-forum.com/t/visibility-controller-instance-variables/111457/2 "2007-08-07T17:30:19Z")

</div>

Vince, assuming action1 does something and then renders to the browser  
then the answer to your question is “yes” but not perhaps in the way  
you were thinking.

The web being a stateless world, nothing is remembered after the end  
of your action1 (unless you take action to store some stuff that you  
can restore up again). Each request, action and response is brand new  
every time. Nothing of the last action, or any action is remembered.

Therefore at the start of action2 there is nothing remembered unless  
you took action to store and restore what you need.

Cheers, --Kip
