Rails: define a method to have advanced data from the db <p>I have a model named <code>Category</code>. I also have a model named <code>Todo</code> (in this model there is <code>boolean</code> column <code>completed</code>).</p> <pre><code>Category has_many :todos Todo belongs_to :category </code></pre> <p>I want to print to view all categories and for each category, how many todo are completed and how many are not are completed</p> <p>How can I do this?</p> <p>Thanks!</p>