# How to pass data from a view to a partial rendered in a layout?

**URL:** <https://www.ruby-forum.com/t/how-to-pass-data-from-a-view-to-a-partial-rendered-in-a-layout/118902>\
**Category:** Rails\
**Created:** [November 1, 2007, 8:30am UTC](https://www.ruby-forum.com/t/how-to-pass-data-from-a-view-to-a-partial-rendered-in-a-layout/118902 "2007-11-01T08:30:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![athem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@athem](https://www.ruby-forum.com/u/athem)\
**Post date:** [November 1, 2007, 8:30am UTC](https://www.ruby-forum.com/t/how-to-pass-data-from-a-view-to-a-partial-rendered-in-a-layout/118902/1 "2007-11-01T08:30:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![athem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@athem](https://www.ruby-forum.com/u/athem)\
**Post date:** [November 1, 2007, 9:50am UTC](https://www.ruby-forum.com/t/how-to-pass-data-from-a-view-to-a-partial-rendered-in-a-layout/118902/2 "2007-11-01T09:50:22Z")

</div>

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/](http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/)

– gw
