Pages

Sunday, May 16, 2010

Parsing parameter through render :partial


Rails tip:

You can pass a variable through a render partial by using locals as the parameter.
Here how the code will look like :

In your main view:

<%= render :partial => 'partialname' , :locals => { :data1 => 'hello' , :data2 => 'world!'}%>

Here is how you access the locals variable:

<%= local_assigns[:data1] %>

No comments:

Post a Comment