How to display join result in view
I need to join three tables using inner join and i did as follows
@posts = SubCategory.joins(products: :posts)
Now I am trying to list the fields for posts table but it is throwing
error as
undefined method `title' for
#<ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_Post:0x9932f84>
i tried something like this i my view but it doen't help
<% @posts.each do |post| %>
<h4><%= post.posts.title %></h4>
<% end %>
Any suggestions
No comments:
Post a Comment