How to pass another flag variable in addition to collections to a partial?

How can I pass a is_featured = true to the following partial?

<%= render :partial => 'stores', :collection => @stores %>

I only need to pass the is_featured in one place (in all other places I call the partial as above.

Answers


You can use the locals option of render

<%= render :partial => 'stores', :collection => @stores, :locals => { :is_featured => is_featured } %>

In the partial you would access it as a method:

<%= is_featured %>

Need Your Help


About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.