ruby on rails - list post in categories -


I have a post model and a client model

Show me a list of categories All posts on one page

I am in every model correctly and I am using related_.

How do I show them in my scene?

Category

  • Post 1
  • Post 2
  • < Li> Post 3

Category name 2

  • Post 1
  • Post 2
  • Post 3

etc ...

thanks

set in your controller @ category:

  @ category = category.fund (: all, include => gt;: post) # you specify your conditions here Can # include:  

Later on each "category.posts" call in the sequence to avoid a query Required for:

category <%> in category for & lt;% & Lt; Strong & gt; & Lt;% = category.name% & gt; & Lt; / Strong & gt; & Lt; Ul & gt; & Lt;% post in post.posts% & gt; & Lt; Li & gt; & Lt;% = post.name% & gt; & Lt; / Li & gt; & Lt;% end% & gt; & Lt; / Ul & gt; & Lt;% end% & gt;

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -