mabid / rails_new

A thoughtfully designed template for building modern Rails apps πŸ”₯ Get started on your new app within minutes instead of hours πŸš—πŸ’¨

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rails_new   Tweet

Build Status

A thoughtfully designed template for building modern Rails apps πŸ”₯

Get started on your new app within minutes instead of hours πŸš—πŸ’¨

Getting started

To get going clone this repository and perform the following steps:

  1. Clone this repository
  2. You can now run bin/configure, which will help you in configuring the template. Alternatively perform all of the following steps manually.
  3. Change application name in config/application.rb.
  4. Update database.yml to reflect the new application name.
  5. Update TODO items in config/environments/production.rb.
  6. If you plan on using Figaro, copy config/application.yml.example to config/application.yml.
  7. ESLint is preconfigured for modern JS with React support (AirBnB styleguide). If you want to use it install packages with npm install, otherwise remove .eslintrc and package.json.
  8. If you don't plan on tracking the template, you can remove the .git directory. Otherwise you can rename the remote:
    $ git remote rename origin rails_new
  9. Add your new remote as appropriate.

Note on Webpacker, the asset pipeline, and ES6

By default ES6 will not work for files in app/assets/javascript since Uglifier will fail to process them. This is why we applied the following change to config/production.rb, which allows you to use ES6 project wide:

-  config.assets.js_compressor = :uglifier
+  config.assets.js_compressor = Uglifier.new(harmony: true)

Also note that for everything to work properly on Heroku, you need to set up your buildpacks like this:

heroku buildpacks:clear
heroku buildpacks:set heroku/nodejs
heroku buildpacks:add heroku/ruby

Optional configurations

  • If you want to use AirBrake, make sure the following 2 environment variables are set:
    • AIRBRAKE_PROJECT_ID
    • AIRBRAKE_API_KEY
  • New Relic 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).

Environment variables

Variable Comment
GOOGLE_ANALYTICS_ID Will be added to the main application layout if set
BLOCK_HTTP_TRACE Disable HTTP TRACE method if set to true/t/1
DATABASE_URL Used for production env, automatically set by Heroku
HTTP_METHOD_BLACKLIST If you want to block more than just TRACE, e.g. "TRACE,OPTIONS"
PORT Port Puma will listen on, defaults to 3000
RAILS_LOG_TO_STDOUT Set by Heroku Ruby buildpack, set manually on other platforms if needed
RAILS_MAX_THREADS Number of Puma threads, defaults to 5

Contents

All of the following have been installed and pre-configured.

Base system

  • Rails 5.1.5
  • Ruby 2.5.0
  • pg for ActiveRecord
  • The app is preconfigured for Google Analytics, just add GOOGLE_ANALYTICS_ID to the environment.

Notes

  • ApplicationDecorator: lightweight alternative to Draper or similar gems.
  • yard is available in development mode. Use yard doc to generate documentation and yard server --reload or yard server --gems to start a local documentation server.
  • Favicons were generated with Real Favicon Generator.
  • There'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.

General

Frontend

All of these are managed by yarn.

Development

Test

Production

Removed

The following default Rails gems have been removed:

About

A thoughtfully designed template for building modern Rails apps πŸ”₯ Get started on your new app within minutes instead of hours πŸš—πŸ’¨


Languages

Language:Ruby 83.8%Language:HTML 13.8%Language:JavaScript 2.3%Language:CSS 0.1%Language:Shell 0.0%