Needs for Rails 5 Boilerplate
I’ve been working with Ruby on Rails more than 3 years and I started feel I need a good template to make a rocket start. What I need for the boilerplate is…
- New Rails version
- UI: Bootstrap, FontAwesome
- Nice template engine (Slim or Haml)
- Includes only basic functions (not fancy features)
- Better to have a basic user authentication (Devise gem)
I could find some good boilerplate for Rails, but they’re a bit different from my needs. Some are too small and some are too big to start with. So finally, I created my own Rails 5 boilerplate.
Please take a look at Github here: https://github.com/takp/rails5-boilerplate
I chose gems only needed seriously, because there are great gems but you may not use it.
- Ruby on Rails 5.0
- Twitter Bootstrap 3
- Slim Template Engine
- Other Gems for debug and test (pry, factory_girl, capybara, rubocop, and so on)
MVC + Service + Decorator
- Models: app/models
- Views: app/views
- Controllers: app/controllers
- Services: app/services
- Decorators: app/decorators
The services helps you to keep your class small. The transactions that does not depends on any other models, or that needs to interact with 2 or 3 models, it’s better to put your codes into service class. So that you can separate the codes, and you can keep your model and controller smaller.
And about the decorators, basically it’s better not to put your codes for views into models. The models should have the codes for business logics. But you may need to make some methods to the models, and if it’s not suitable for models, you can put them into decorators folders. It’s like an helper files for the models.
How to use?
$ git clone email@example.com:takp/rails5-boilerplate.git $ cd rails5-boilerplate $ bundle install
After configure your credentials for database connections,
$ bundle exec rake db:create $ bundle exec rake db:migrate $ bin/rails server
And you can see the boilerplate top page. You can get more details info from the Github page (Rails5 boilerplate).
Please try it and tell me any suggestions if any. I’m happy if you could give me github star. Thanks.