{"id":13747318,"url":"https://github.com/lockstep/rails_new","last_synced_at":"2025-04-13T08:26:49.579Z","repository":{"id":37952166,"uuid":"88722158","full_name":"lockstep/rails_new","owner":"lockstep","description":"A thoughtfully designed template for building modern Rails apps. Get started in minutes instead of hours 🔥🚀","archived":false,"fork":false,"pushed_at":"2023-07-31T08:32:45.000Z","size":2779,"stargazers_count":165,"open_issues_count":10,"forks_count":31,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-24T11:54:30.773Z","etag":null,"topics":["figaro","heroku","pry","rails","rspec","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lockstep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-19T08:45:28.000Z","updated_at":"2025-01-21T03:47:48.000Z","dependencies_parsed_at":"2024-01-03T02:24:32.718Z","dependency_job_id":"7e6e4513-7949-464a-895d-0df432965ca0","html_url":"https://github.com/lockstep/rails_new","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lockstep%2Frails_new","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lockstep%2Frails_new/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lockstep%2Frails_new/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lockstep%2Frails_new/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lockstep","download_url":"https://codeload.github.com/lockstep/rails_new/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248683019,"owners_count":21144864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["figaro","heroku","pry","rails","rspec","ruby","ruby-on-rails"],"created_at":"2024-08-03T06:01:24.956Z","updated_at":"2025-04-13T08:26:49.555Z","avatar_url":"https://github.com/lockstep.png","language":"Ruby","readme":"# rails_new\n\n[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Save%20hours%20of%20your%E2%8F%B1%EF%B8%8F%20with%20this%20template%20for%20building%20modern%20%23Rails%20apps%20%F0%9F%92%AF%F0%9F%94%A5%20\u0026url=https://github.com/lockstep/rails_new\u0026via=locksteplabs\u0026hashtags=rubyonrails)\n\n![Build Status](https://circleci.com/gh/lockstep/rails_new.svg?style=shield)\n\nA thoughtfully designed template for building modern Rails apps 🔥\n\nGet started on your new app within minutes instead of hours 🚗💨\n\n- [rails_new](#railsnew)\n  - [Getting started](#getting-started)\n  - [Optional configuration options](#optional-configuration-options)\n  - [Environment variables](#environment-variables)\n  - [Contents](#contents)\n    - [Base system](#base-system)\n    - [General](#general)\n    - [Frontend](#frontend)\n    - [Development](#development)\n    - [Test](#test)\n    - [Production](#production)\n  - [Removed](#removed)\n  - [Notes](#notes)\n    - [`Account` vs `User`](#account-vs-user)\n    - [Heroku Buildpacks](#heroku-buildpacks)\n    - [React](#react)\n    - [TypeScript](#typescript)\n    - [Hot Module Replacement (HMR)](#hot-module-replacement-hmr)\n    - [JavaScript/TypeScript Tests](#javascripttypescript-tests)\n    - [Polyfills](#polyfills)\n    - [Custom classes](#custom-classes)\n    - [`Gemfile.dev` / `Gemfile.dev.lock`](#gemfiledev--gemfiledevlock)\n    - [`Rack::RejectTrace` middleware](#rackrejecttrace-middleware)\n    - [Favicons](#favicons)\n  - [Docker](#docker)\n    - [Usage examples:](#usage-examples)\n  - [TODO](#todo)\n  - [License](#license)\n\n## Getting started\n\nTo get going clone this repository and perform the following steps:\n\n1. Run `rails credentials:edit` to re-generate `config/master.key` and create `config/credentials.yml.enc`.\n1. If your application requires `ActiveStorage`, run `rails active_storage:install` to generate a migration that creates the necessary tables. Use `rails db:migrate` to run the migration.\n1. You can now run `bin/configure`, which will help you in configuring the template.\n\nAs an alternative to running the script you can perform all of the following steps manually.\n\n1. Change application name in `config/application.rb`.\n1. Update `database.yml` to reflect the new application name.\n1. Update `TODO` items in `config/environments/production.rb`.\n1. If you plan on using Figaro, copy `config/application.yml.example` to `config/application.yml`.\n1. ESLint is preconfigured for modern JS with React support (using [Prettier](https://prettier.io)). If you want to use it install packages with `npm install` / `yarn [install]`, otherwise remove `.eslintrc` and `package.json`.\n1. If you don't plan on tracking the template, you can remove the remote, otherwise rename it and add your new remote as appropriate.:\n   ```shell\n   $ git remote rename origin rails_new\n   $ git remote add origin ...\n   ```\n\n## Optional configuration options\n\n- If you want to use [Sentry](https://sentry.io), you'll need to:\n  1. Create two projects under your organization on Sentry. This way you can keep frontend and backend errors separate.\n  1. Set `SENTRY_DSN_BACKEND` and `SENTRY_DSN_FRONTEND` environment variables. Both are optional - errors will only be reported if the respective variable is set.\n- [New Relic](https://newrelic.com) is pre configured in `config/newrelic.yml`, but you need to comment in the environment variables for it work on Heroku (lines 10 and 17).\n- The app is preconfigured for Google Analytics, just add `GOOGLE_ANALYTICS_ID` to the environment.\n- We prefer to use vanilla Sidekiq for worker/queue management. If you prefer to use ActiveJob please see the configuration/options that were removed in [59cf38d](https://github.com/lockstep/rails_new/commit/59cf38d5872eb8bd9267a5c0ae95aa39396c7130).\n\n## Environment variables\n\n| Variable                     | Comment                                                                 |\n| ---------------------------- | ----------------------------------------------------------------------- |\n| SENTRY_DSN_BACKEND           | Used to report backend errors to Sentry.                                |\n| SENTRY_DSN_FRONTEND          | Used to report frontend errors to Sentry.                               |\n| BLOCK_HTTP_TRACE             | Disables HTTP `TRACE` method if set to true/t/1                         |\n| BUNDLE_GEMFILE               | Useful when using a [Gemfile.dev](#gemfiledev---gemfiledevlock)         |\n| DATABASE_URL                 | Used for `production` env, automatically set by Heroku                  |\n| GOOGLE_ANALYTICS_ID          | Will be added to the main application layout if set                     |\n| HOST                         | Your base URI, e.g. https://myapp.herokuapp.com                         |\n| NEW_RELIC_APP_NAME           | Used in `config/newrelic.yml`                                           |\n| NEW_RELIC_LICENSE_KEY        | Used in `config/newrelic.yml`                                           |\n| PORT                         | Port Puma will listen on, defaults to 3000                              |\n| RACK_TIMEOUT_SERVICE_TIMEOUT | Limit for `Rack::Timeout`, defaults to 15 seconds                       |\n| RAILS_LOG_TO_STDOUT          | Set by Heroku Ruby buildpack, set manually on other platforms if needed |\n| RAILS_MAX_THREADS            | Number of Puma threads, defaults to 5                                   |\n| REDIS_URL                    | Used in `config/cable.yml`                                              |\n| WEB_CONCURRENCY              | Number of Puma workers. We default to threads only, no workers          |\n\n## Contents\n\nAll of the following have been installed and pre-configured:\n\n### Base system\n\n- Ruby\n- Ruby on Rails\n- PostgreSQL \u003e= 9.2\n- [pg](https://github.com/ged/ruby-pg) for `ActiveRecord`\n- NodeJS\n\nNOTE: We recommend that you install and manage these system dependencies using\na combination of [Homebrew](https://brew.sh/) (Postgres),\n[asdf-vm](https://asdf-vm.com/#/) (Ruby, NodeJS) and\n[Bundler](https://bundler.io/) (Ruby on Rails). If you are starting fresh on\na new system you may want to manage these package managers with a script\nlike the [thoughtbot laptop script](https://github.com/thoughtbot/laptop) with\nthe option to add your own opinionated extensions,\ne.g. [this](https://github.com/hiattp/dotfiles). Your code base should be under\nversion control, why not your system toolkit and configuration as well?\n\n### General\n\n- [devise](https://github.com/plataformatec/devise)\n- [figaro](https://github.com/laserlemon/figaro)\n- [foreman](https://github.com/ddollar/foreman)\n- [fast_jsonapi](https://github.com/Netflix/fast_jsonapi)\n- [pundit](https://github.com/elabs/pundit)\n- [sidekiq](https://github.com/mperham/sidekiq)\n\n### Frontend\n\nAll of these are managed by `yarn`.\n\n- [bootstrap4](https://www.npmjs.com/package/bootstrap-v4-dev)\n- [jquery](https://www.npmjs.com/package/jquery)\n- [jquery-ujs](https://www.npmjs.com/package/jquery-ujs/)\n- [popper.js](https://www.npmjs.com/package/popper.js)\n\n### Development\n\n- [Brakeman](https://github.com/presidentbeef/brakeman)\n- [bullet](https://github.com/flyerhzm/bullet)\n- [letter_opener](https://github.com/ryanb/letter_opener)\n- [memory_profiler](https://github.com/SamSaffron/memory_profiler)\n- [newrelic_rpm](https://github.com/newrelic/rpm)\n- [nullalign](https://github.com/tcopeland/nullalign)\n- [pry](https://github.com/rweng/pry-rails)\n- [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug)\n- [pry-doc](https://github.com/pry/pry-doc)\n- [rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler)\n- [RuboCop](https://github.com/bbatsov/rubocop)\n\n### Test\n\nRspec has been preconfigured for Rails 5.1+ system tests.\n\n- No need to `require 'rails_helper`, we do it in `.rspec`\n- [bundler-audit](https://github.com/rubysec/bundler-audit) (runs on CircleCI)\n- [capybara](https://github.com/teamcapybara/capybara)\n- [factory_bot_rails](https://github.com/thoughtbot/factory_bot_rails)\n- [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers)\n- [webmock](https://github.com/bblimke/webmock)\n\n### Production\n\n- [sentry-ruby](https://github.com/getsentry/sentry-ruby)\n- [heroku-deflater](https://github.com/romanbsd/heroku-deflater)\n- [lograge](https://github.com/roidrage/lograge)\n- [rails_12factor](https://github.com/heroku/rails_12factor)\n- [rack-timeout](https://github.com/heroku/rack-timeout): Configured via env variables, see [documentation](https://github.com/heroku/rack-timeout#configuring)\n- [secureheaders](https://github.com/twitter/secureheaders)\n\n## Removed\n\nThe following default Rails gems have been removed:\n\n- [coffee-rails](https://github.com/rails/coffee-rails)\n- [jbuilder](https://github.com/rails/jbuilder)\n\n## Notes\n\n### `Account` vs `User`\n\nAuthentication concerns (your typical `Devise` configuration) are handled by the `Account` model. To connect this to one of several potential user roles the polymorphic `authenticatable` relationship is used.\n\n### Heroku Buildpacks\n\nNote that for everything to work properly on Heroku you need to set up your buildpacks like this:\n\n```\nheroku buildpacks:clear\nheroku buildpacks:add heroku/metrics\nheroku buildpacks:set heroku/nodejs\nheroku buildpacks:add heroku/ruby\n```\n\n### React\n\nReact support has been preconfigured together with `react-rails`.\n\nWhen creating a new component you want to mount in the view, place it under the `views` folder. `react-rails` will perform module lookup relative to that folder and automatically require it under the hood so it gets included in the `application` pack. For example, calling the following helper in your view file:\n\n```ruby\nreact_component(\"dashboard/properties_list\")\n```\n\nwill require `views/dashboard/properties_list` and mount it in place of the helper element. See the [docs](https://github.com/reactjs/react-rails) for details about working with `react-rails`.\n\n### TypeScript\n\nTypeScript is supported out of the box.\n\nIt is important to note that TypeScript code is loaded by `babel-loader`. Because of that, you need to perform type checking in a separate process. This could either be your editor, or running `yarn types-watch` in your terminal to compile your code in watch mode.\n\nThis will not interfere with HMR (see below) as TypeScript compiler is instructed only to type-check your code, not to emit compiled modules.\n\nFor extra safety, there is a CI build step that runs `tsc` to make sure TypeScript code compiles\n\n### Hot Module Replacement (HMR)\n\nHMR is also supported out of the box. All you need to do is hot-export your module, like so:\n\n```js\nimport React from \"react\";\nimport { hot } from \"react-hot-loader/root\";\n\nclass Welcome extends React.Component {\n  render() {\n    return \u003ch1\u003eHello, {this.props.name}\u003c/h1\u003e;\n  }\n}\n\nexport default hot(Welcome);\n```\n\nThis will allow you to continue working on your JS code without losing application state in the browser.\n\n### JavaScript/TypeScript Tests\n\nThe repo comes pre-configured with `jest`. You can write your tests in JavaScript or TypeScript.\n\nWe're following the convention of placing tests next to the file they're testing. They will be run as long as they have `test`, (e.g. `MyComponent.test.ts`) in the name.\n\nYou are encouraged to place your testing utility files under `app/javascript/test`.\n\nTo run your tests, run:\n\n```\nyarn test\n```\n\n### Polyfills\n\nPolyfills are included automatically thanks to `@babel/preset-env`. See `babel.config.js` for configuration options.\n\n### Custom classes\n\n- `ApplicationDecorator`: lightweight alternative to Draper or similar gems.\n- `ApplicationForm`: Minimal form class based on `ActiveModel`.\n- `ApplicationPresenter`: a subclass of `ApplicationDecorator` for presenters, includes tag helpers.\n\nAll custom classes are fully documented with [yard](https://yardoc.org) and come with generators.\n\nUse `yard doc` to generate documentation and `yard server --reload` or `yard server --gems` to start a local documentation server.\n\n### `Gemfile.dev` / `Gemfile.dev.lock`\n\nIf you want to add specific gems for development that may not be interesting for other developers, you can add a `Gemfile.dev` (ignored by our `.gitignore`). Gems listed there can be installed with `bundle install --gemfile Gemfile.dev` and the resulting lock file is gitignored too.\n\nExample `Gemfile.dev`:\n\n```ruby\nsource 'https://rubygems.org'\n\neval_gemfile 'Gemfile'\n\ngem 'awesome_print'\n```\n\nThe `eval_gemfile` line will ensure that all gems from your regular `Gemfile` will be included too. The `BUNDLE_GEMFILE` variable can be used to let Bundler now which gemfile to use:\n\n```\nBUNDLE_GEMFILE=Gemfile.dev rails c\n```\n\n### `Rack::RejectTrace` middleware\n\nThere's a custom middleware (`Rack::RejectTrace`) for completely disabling the HTTP TRACE method as required by certain security audits. It can be enabled via the `BLOCK_HTTP_TRACE` environment variable.\n\n### Favicons\n\nFavicons were generated with [Real Favicon Generator](https://realfavicongenerator.net/), consider using the same tool when replacing them for your project.\n\n## Docker\n\nFor those wishing to use Docker for development the whole app has been dockerized and the setup is fairly well-documented. Features:\n\n- Images use [Alpine Linux](https://alpinelinux.org) to keep their size small.\n- `docker-compose.yml` sets up and starts Postgres, Redis, Sidekiq, Rails and the Webpack dev server.\n- Uses a persistent bundle cache, so there's no need to rebuild the image to add gems.\n- Persistent volumes for Postgres and Redis.\n- No exposed ports except for Rails (mapped to port `3000` by default)\n\nThe following files relate to our Docker setup:\n\n- `Dockerfile`: main setup for the `app` container\n- `docker-compose.yml`: Ties Postgres, Redis and `app` together\n- `docker-entrypoint.sh`: Custom entry point to facilitate bundle caching\n- `Procfile.docker`: Used by the entrypoint script to bring up services\n- `.dockerignore`: similar to `.gitignore`, specifies files we don't want copied into the container\n\n### Usage examples:\n\nStart the environment and build the images if necessary:\n\n```sh\n$ docker-compose up --build\nBuilding app\n[Step 1/12 : FROM ruby:2-alpine\n ---\u003e 8302cc790fbf\nStep 2/12 : RUN apk update \u0026\u0026 apk add --update --no-cache   build-base   chromium   chromium-chromedriver   git   imagemagick   libxml2-dev   libxslt-dev   nodejs   tzdata   postgresql-dev\n ---\u003e Using cache\n ---\u003e 9d1d0b398c26\nStep 3/12 : RUN bundle config build.nokogiri --use-system-libraries\n ---\u003e Using cache\n ---\u003e 0a5ca06d7700\nStep 4/12 : WORKDIR /app\n ---\u003e Using cache\n ---\u003e c61498ba7e64\n[...]\n```\n\nStart the environment without (re-)building images (add `-d` to daemonize):\n\n```sh\n$ docker-compose up\nStarting rails_new_postgres_1 ... done\nStarting rails_new_redis_1    ... done\nStarting rails_new_app_1      ... done\nAttaching to rails_new_postgres_1, rails_new_redis_1, rails_new_app_1\n[...]\n```\n\nStop the environment but keep the containers:\n\n```sh\n$ docker-compose stop\nStopping rails_new_app_1      ... done\nStopping rails_new_postgres_1 ... done\nStopping rails_new_redis_1    ... done\n```\n\nStop the environment and remove the containers:\n\n```sh\n$ docker-compose down\nStopping rails_new_app_1      ... done\nStopping rails_new_postgres_1 ... done\nStopping rails_new_redis_1    ... done\nRemoving rails_new_app_1      ... done\nRemoving rails_new_postgres_1 ... done\nRemoving rails_new_redis_1    ... done\nRemoving network rails_new_default\n```\n\nExecute a command inside the `app` container:\n\n```sh\n$ docker-compose exec app ruby -v\nruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-musl]\n```\n\nExecute a command inside the `app` container that needs env variables:\n\n```sh\n$ docker-compose exec --env RAILS_ENV=test app rails db:setup\nCreated database 'rails_new_test'\n-- enable_extension(\"plpgsql\")\n   -\u003e 0.0251s\n-- create_table(\"users\", {:force=\u003e:cascade})\n   -\u003e 0.0366s\n```\n\nAdding a new gem (does not require image rebuild):\n\n```sh\n# update Gemfile\n$ docker-compose exec app bundle\n```\n\nRunning specs:\n\n```sh\n$ docker-compose exec app rspec\n....................\n\nFinished in 0.47352 seconds (files took 16.36 seconds to load)\n20 examples, 0 failures\n```\n\n## TODO\n\nNothing right now.\n\n## License\n\nThis project is MIT licensed, see [LICENSE](./LICENSE).\n","funding_links":[],"categories":["Ruby","Starters/Boilerplates"],"sub_categories":["Articles"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flockstep%2Frails_new","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flockstep%2Frails_new","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flockstep%2Frails_new/lists"}