I have a Vendor controller for show:
def show
@vendor = Vendor.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @vendor }
end
end
In my View for Reviews (where Vendor :has_many Reviews)
<% if @vendor.reviews.empty? %>
No Analyst Reports yet
<% else %>
<% for review in @vendor.reviews %>
<%= review.user_id %>
<%= review.summary %><br />
<hr class="span-5" />
<% end %>
<% end %>
So I am basically going through a 'for' loop for all the reviews for a particular vendor (this has been a tricky concept for me but it seems to work).
So: I want to display the User.name and user.email. I know what the user_id for each corresponding Review is (review.user_id) but I don't know how to display values for the User model.
I thought using find_by_id would work but it doesn't recognize User.
Help?