# Render :action "call method first?"

**URL:** <https://www.ruby-forum.com/t/render-action-call-method-first/103459>\
**Category:** Rails\
**Created:** [May 6, 2007, 12:34pm UTC](https://www.ruby-forum.com/t/render-action-call-method-first/103459 "2007-05-06T12:34:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [May 6, 2007, 12:34pm UTC](https://www.ruby-forum.com/t/render-action-call-method-first/103459/1 "2007-05-06T12:34:44Z")

</div>

Hi,

I know when I call:

render :controller =\> ‘some’, :action =\> ‘thing’

It doesn’t call the method ‘thing’ before render the template  
‘thing.rhtml’, but I need some instance variable which are in the  
‘thing’ method, how can I let it call the method ‘thing’ and then render  
the template?

Regards,  
Jamal

---

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [May 6, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/render-action-call-method-first/103459/2 "2007-05-06T13:24:31Z")

</div>

I usually set up another method called “set\_up\_country\_list” or  
whatever, which sets up the instance variables that you need. Then  
your original “thing” method, and this other action, can both call  
“set\_up\_country\_list” before rendering the view.

Chris

On May 6, 11:34 am, Jamal S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [May 6, 2007, 1:39pm UTC](https://www.ruby-forum.com/t/render-action-call-method-first/103459/3 "2007-05-06T13:39:51Z")

</div>

Chris M. wrote:

> I usually set up another method called “set\_up\_country\_list” or  
> whatever, which sets up the instance variables that you need. Then  
> your original “thing” method, and this other action, can both call  
> “set\_up\_country\_list” before rendering the view.
> 
> Chris
> 
> On May 6, 11:34 am, Jamal S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

I did not understand what you mean?

def fake

end

def thing

end

def call\_from\_here  
in this template view call fake method to setup instance variabe which  
can be used in thing template???:S  
end
