Hotwire is amazing. It took all the good things Rails already did and improved it into a technique that allows you to write little(sometimes none) Javascript.
That's great for developers that want to write their full stack application but don't want to have trouble writing or learning React/Typescript/Vue and the whole modern stack frontend developers use these days.
Real time updates with turbo-stream which abstracts all the javascript part from Action Cable and turbo-frames for replacing only parts of pages gives your rails application the look and feel of any other app writen in React or any JS library.
So, give it a chance and try it yourself to build something with it.
I wrote this application based on this tutorial with some changes that combined serve as the foundation for all my Rails projects.
I used Rspec as a test framework instead of Mini-test and I wrote a small class to dry-up a the controller responses. Normally I use the responders gem for this, but somehow it's not working with flash messages and turbo stream response format.
- Docker. I always use docker no matter what. If you get my laptop the only thing installed is a docker desktop application. Nothing else, no database, no programing language, nothing. Even when I need to run one ruby script, I use docker. Follow this tutorial for docker and rails quick start.
- Devise Gem for user management, including login, registration, forget the password, and so on.
- Simple Form gem plays nice with devise so you can build forms with ease. You set up one time and all your forms will be ready to reuse throughout the whole application.
- Rspec gem for tests. Nothing against the default rails test framework, but I feel much more productive with Rspec. Along with it, I also use shoulda-matchers, faker, factory_bot_rails, and rspec-its.
- Rubocop. It helps me write better quality code and once you use it's hard to go back.
- Dotenv-rails for better management of environment variables.
- Simplecov for checking if I'm covering at least 90% of the project with tests.
Normally I write tests for all models trying to cover all possible edge cases.
Then I write feature tests using capybara which also acts as integration and end 2 end tests. If I'm writing an API-only application then I favor requests tests. Do not write controller tests. Favor always features or requests over controller tests.
- Install docker
- Everything is set, just run spin up the container.
docker compose run --rm web bash rails db:prepare
docker compose up
You can run the tests using rspec:
docker compose run --rm web bash bundle exec rspec
This version is not deployed anywhere but you can see how it is supposed to work here.