Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the count of all records of a model in Rails console

I am new to Rails.

I have an ActiveRecord model called Post. I'd like to get count of all the records of the Post model. How can I accomplish this?

Thanks in advance for your help.

like image 492
decoder Avatar asked Sep 20 '25 02:09

decoder


1 Answers

Post.count

is what you are looking for.

like image 102
Sander Garretsen Avatar answered Sep 22 '25 17:09

Sander Garretsen