athem
2007-Nov-01 07:30 UTC
How to pass data from a view to a partial rendered in a layout?
In the application I''m working on, a layout renders a partial that displays a breadcrumb navigation bar across the top of a page. In other words, the layout renders a partial that displays breadcrumbs. But the navigation bar rendered by a partial in a layout needs to use data from the view to determine which breadcrumbs to display. My question is: how can data be passed from a view to a partial rendered in a layout? The ActionController::Layout::ClassMethods explains that data in a view is shared by a partial rendered by the view (using :locals), but I see no reference for how to pass data from a view to a partial being rendered in the layout in which the view "resides." 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 -~----------~----~----~----~------~----~------~--~---
Greg Willits
2007-Nov-01 08:46 UTC
Re: How to pass data from a view to a partial rendered in a layout?
On Nov 1, 2007, at 12:30 AM, athem wrote:> My question is: how can data be passed from a view to a partial > rendered in a layout? The ActionController::Layout::ClassMethods > explains that data in a view is shared by a partial rendered by the > view (using :locals), but I see no reference for how to pass data from > a view to a partial being rendered in the layout in which the view > "resides." Thanks.This article explains some different techniques for doing that: http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/ -- gw --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- Rails view spec expectations/matchers
- How to know in the layout what view was rendered?
- template.expect_render fails when partial is rendered from a helper
- how to create local subroutines properly in rails?
- rspec-rails render_views doesn't render layouts? / how to check flash isn't rendered