nephish
2007-Jan-11 20:52 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton
2007-Jan-11 20:58 UTC
Re: does a partial have access to all the variables of the calling controller
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" <nephish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: "Ruby on Rails: Talk" <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Sent: Thursday, January 11, 2007 2:52 PM Subject: [Rails] 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 > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sheldon Hearn
2007-Jan-11 20:59 UTC
Re: does a partial have access to all the variables of the calling controller
On Jan 11, 10:52 pm, "nephish" <neph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
shawn bright
2007-Jan-11 22:47 UTC
Re: does a partial have access to all the variables of the calling controller
cool, thanks very much ! shawn On 1/11/07, Sheldon Hearn <sheldonh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > > On Jan 11, 10:52 pm, "nephish" <neph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 > > 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. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---