Answer the question
In order to leave comments, you need to log in
How to display posts for a project?
Hi friends!
I can not understand in any way, I have a problem with these requests.
I honestly tried to solve it myself, but I didn’t get it.
Selection of projects
@posts_project =
Project
.limit(3)
.order(created_at: :desc)
Answer the question
In order to leave comments, you need to log in
@projects = Project.limit(3).order(created_at: :desc)
@projects.each do |project|
project.posts.limit(5).each {|post| @posts << post}
end
@posts_project = @posts.order(created_at: :desc)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question