Rails_components_template

screenshot of Rails_components_template

Rails Application Template with Komponent.io and other opinionated decisions

Overview

This article discusses a Rails Application Template that incorporates various opinionated decisions and tools to enhance the development process. The template includes features such as Komponent.io, stimulus, webpacker, postcss, stylelint, normalize.css, foreman, dotenv-rails, browserlint, slim, rake tasks, guard, pry, factory_bot_rails, faker, annotate, awesome_print, airbrake, newrelic_rpm, mutant, and overcommit.

Features

  • Komponent.io integration: The template uses Komponent.io to modularize the front-end code and improve code reusability.
  • Stimulus integration: It includes support for Stimulus, a JavaScript framework for building rich interactive interfaces.
  • Webpacker usage: Sprockets is replaced with Webpacker, which offers better front-end asset management and compilation.
  • PostCSS usage: Instead of SASS, the template uses PostCSS along with postcss-import, postcss-cssnext, and postcss-nested for advanced CSS processing.
  • Stylelint configuration: The template includes Stylelint with a predefined configuration to enforce consistent CSS coding practices.
  • Normalize.css inclusion: Normalize.css is added to provide a consistent base for styling across different browsers.
  • Foreman integration: Foreman is included with default Procfile configurations for Heroku deployment and development environment.
  • Custom user handling for Postgres: The template provides custom user handling for Postgres through environment variables.
  • .env support: .env files are supported using the dotenv-rails gem for managing environment-specific variables.
  • Browserlint integration: Browserlint is included with default configurations to check browser compatibility of the code.
  • Slim template engine: The template replaces ERB with Slim, a more concise and readable template engine for HTML markup.
  • Erb to Slim conversion task: A rake task is included to convert existing ERB templates to Slim using the html2slim gem.
  • Rake hook for assets precompilation: The template handles yarn and webpacker compilation during the assets:precompile rake task on Heroku.
  • Redis integration for Action Cable: The redis gem is added for integrating Action Cable with Redis as a storage backend.
  • Guard usage: Guard is configured with extensions for migrations, RSpec, RuboCop, shell, and Spring for automatically running related tasks upon file changes.
  • Pry integration: Pry is included with extensions for rescue and byebug, enhancing debugging capabilities in Rails console.
  • Factory Bot Rails: The template replaces fixtures with Factory Bot Rails for generating test data.
  • Faker integration: Faker is added and configured to generate fake data for test cases.
  • Annotate database structure: The gem annotate is used to automatically add comments with database structure annotations in model files.
  • Awesome Print integration: The template includes the Awesome Print gem for a more readable output in the Rails console.
  • Error handling and monitoring: Airbrake and New Relic RPM are integrated to provide error handling and monitoring capabilities in the application.
  • Rake mutant tasks: The template includes rake tasks for mutation testing using the Mutant gem, configured with .mutant_subjects and .mutant_ignored_subjects files.
  • Spec and mutant default rake tasks: The default rake task is set to run the specs and mutant tasks for convenient test execution.
  • RAILS_EAGER_LOAD flag: A flag is included to detect NameErrors on CI and resolve the issue of mutant running with uninitialized constants.
  • Overcommit integration: Overcommit is configured for executing pre-commit hooks to enforce consistent code quality and formatting.

Summary

The Rails Application Template discussed in this article provides an opinionated set of decisions and integrations to enhance the development process. It includes features such as Komponent.io, Stimulus, Webpacker, PostCSS, Stylelint, Normalize.css, Foreman, dotenv-rails, Browserlint, Slim, rake tasks, Guard, Pry, Factory Bot Rails, Faker, Annotate, Awesome Print, Airbrake, New Relic RPM, Mutant, and Overcommit. By following the installation guide, developers can quickly set up a Rails application with these features and improve their productivity and code quality.