# Does a partial have access to all the variables of the calli

**URL:** <https://www.ruby-forum.com/t/does-a-partial-have-access-to-all-the-variables-of-the-calli/82567>\
**Category:** Rails\
**Created:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/does-a-partial-have-access-to-all-the-variables-of-the-calli/82567 "2007-01-19T16:31:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/does-a-partial-have-access-to-all-the-variables-of-the-calli/82567/1 "2007-01-19T16:31:24Z")

</div>

hey there,

i have a group\_controller

in there is an action called run\_reports  
in the \_run\_reports.rhml view, i call two partials that are also in the  
group\_controller.  
do those partials have access to the varibles declared in the  
run\_reports action?  
if so, this would save me a lot of repeated code,  
if so, how do i do it ? make them @class variables ?

thanks

---

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [September 25, 2007, 10:33pm UTC](https://www.ruby-forum.com/t/does-a-partial-have-access-to-all-the-variables-of-the-calli/82567/2 "2007-09-25T22:33:55Z")

</div>

On Jan 11, 10:52 pm, “nephish” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hey there,
> 
> i have a group\_controller
> 
> in there is an action called run\_reports  
> in the \_run\_reports.rhml view, i call two partials that are also in the  
> group\_controller.  
> do those partials have access to the varibles declared in the  
> run\_reports action?

See the API documentation for the render() method:

[http://api.rubyonrails.com/classes/ActionController/Base.html#M000206](http://api.rubyonrails.com/classes/ActionController/Base.html#M000206)

Check out the section called “Rendering partials”. You’ll see that you  
can pass variables from the calling scope into the partial as local  
variables in its scope, using the :partials option.

Ciao,  
Sheldon.

---

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [September 25, 2007, 10:44pm UTC](https://www.ruby-forum.com/t/does-a-partial-have-access-to-all-the-variables-of-the-calli/82567/3 "2007-09-25T22:44:53Z")

</div>

Hi nephish

Partials are just part of a view and you have access in any view to all  
the  
instance variables (e.g., @anything) in the controller action that  
called  
the view.

hth,  
Bill  
----- Original Message -----  
From: “nephish” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: “Ruby on Rails: Talk” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Thursday, January 11, 2007 2:52 PM  
Subject: [Rails] does a partial have access to all the variables of the  
calling controller

---

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [September 25, 2007, 10:46pm UTC](https://www.ruby-forum.com/t/does-a-partial-have-access-to-all-the-variables-of-the-calli/82567/4 "2007-09-25T22:46:50Z")

</div>

cool, thanks very much !  
shawn
