I’m learning rails and I’m just trying to get the basics down.
I just installed devise and created a home controller. If I want to get the number of users (just return the number of records in the db), what should I do from the home controller? It should interact with a model, right? Can the home controller interact with the users model and the home model? Or is that bad practice?
I know I could do a simple google search for this, but I have a lot of questions and Stackoverflow is legit. 🙂
Take it a step further?
How would I get a ‘live feed’ so that the count changes on the home page when a record is added?
You can get a count of the users using
User.count.In your template, you can add something like