Reputation: 365
I have a view that is like this:
render :partial => 'shared/_address', :locals => {:address => order.bill_address}
With a partial that looks like this:
<b><%= address.name %></b><br/>
<%= raw address.address_lines('<br/>') %><br/>
<%= address.city_state_zip %><br/>
There are multiple instances of the partial rendered on a page. Instead of having it display address.name, how can I modify my render :partial line so that I am passing on a custom string e.g. "Future Shipping Address" instead of having to use address.name?
So the code would look like below:
<b>STRING GOES HERE</b><br/>
<%= raw address.address_lines('<br/>') %><br/>
<%= address.city_state_zip %><br/>
Upvotes: 6
Views: 2296
Reputation:
view:
render 'shared/_address', address: order.bill_address, custom_string: 'foobar'
partial:
<b><%= custom_string %></b>
<%= raw address.address_lines('<br/>') ....
Upvotes: 2
Reputation: 8169
Try:
render :partial => 'shared/address', :locals => {:my_string=>"my string", :address => order.bill_address}
in partial
<b><%= my_string %></b><br/>
<%= raw address.address_lines('<br/>') %><br/>
<%= address.city_state_zip %><br/>
Upvotes: 4