Reputation: 47096
I am using rails 3.1. I have a view products/show.html.erb
and I call a partial like this
<%= render 'productrelationships/relatedproduct',:collection => @product.relatedproducts %>
and i access it in this way inside my partial (productrelationship/_relatedproduct
)
<% logger.error 'Related Products ' + relatedproduct.inspect %>
The inspect returns a nil. But if I try the same inside my show.html.erb, it is not nil. There is some mistake in passing the value. What am I doing wrong?
Upvotes: 1
Views: 265
Reputation: 2741
Need to specify the local variable.
<%= render :partial => 'productrelationships/relatedproduct',
:collection => @product.relatedproducts,
:as => :relatedproduct %>
Upvotes: 0
Reputation: 47096
Found the answer. It started working when i added :partial
while rendering
<%= render :partial => 'productrelationships/relatedproduct',:collection => @product.relatedproducts %>
Upvotes: 2