Hi, I''ve got a partial that I call from more than one view. I need it to be slightly different when called from one of the views. Does rails set a variable to tell the partial which action or view is calling it, and if so, how? Thank you. Regards, Rich --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can get the action from the params hash, params[:action] Duzenbury, Rich wrote:> Hi, > > I''ve got a partial that I call from more than one view. I need it to be > slightly different when called from one of the views. Does rails set a > variable to tell the partial which action or view is calling it, and if > so, how? > > Thank you. > > Regards, > Rich > > > >-- Sincerely, William Pratt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, <%= controller.action_name %> Thanks. Regards, Rich> -----Original Message----- > From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of > Duzenbury, Rich > Sent: Wednesday, September 26, 2007 10:49 AM > To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > Subject: [Rails] which action? > > > Hi, > > I''ve got a partial that I call from more than one view. I > need it to be slightly different when called from one of the > views. Does rails set a variable to tell the partial which > action or view is calling it, and if so, how? > > Thank you. > > Regards, > Rich > > > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 9/26/07, Duzenbury, Rich <RDuz-lc0hzAU4LMUAvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I''ve got a partial that I call from more than one view. I need it to be > slightly different when called from one of the views. Does rails set a > variable to tell the partial which action or view is calling it, and if > so, how?You''ve figured out how to get the action name, but I would suggest that this technique tends to make your code very "brittle". A better approach might be to pass a variable to the partial through the call to render() using the :locals option. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---