I am trying to count the number of questions in each subject and then display the question count for each subject next to the subject name:
Model has_many :questions
Controller def index @subjects = Subject.order(:title) @question_number = Question.find(???).count end end
View <a href="/.../<%= subject.id %>"><%= subject.title %> (<%= @question_number %>)</a>
The questions table has a subject_id attribute and this is what I want to query on
Can't understand how to find the count for each subject in the @subjects hash and then display with the associated subject
Dave