does a partial have access to all the variables of the calling controller

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

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

See the API documentation for the render() method:

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.

cool, thanks very much ! shawn