Skip to content

A starter blueprint for fast tracking Rails development

License

Notifications You must be signed in to change notification settings

dalezak/rails-blueprint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 Cannot retrieve latest commit at this time.

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Rails Blueprint

A starter blueprint to help fast track setting up a new Rails application.

Getting Started

To get started, simply clone this repo into a folder with the name of your application.

Clone Repo

Replace my_app with the name of your application.

git clone https://github.com/dalezak/rails-blueprint.git my_app

Then move through the list below doing any of the sections your application needs. If you already have Rails setup, then skip the Setup Environment section, or if you don't want Soft Deletes just move past it.

Setup Environment

Setup your local environment with Ruby, Rails and Node.

Install Ruby

Visit Rails > Getting Started > Installing Ruby for instructions on installing the Ruby language.

ruby -v 
Install RVM

Visit RVM > Install for instructions on setting up RVM so you can easily switch between different version of Ruby.

rvm --default use 3.0.0 
Install Node

Visit Rails > Getting Started > Installing Node for instructions on setting up Node and Yarn.

npm -v
yarn -v
Install Rails

Visit Rails > Getting Started for instructions on installing Rails framework.

gem install rails -v 7.0.0
rails -v

Install Database

Install a local database.

Install Postgres

Visit Postgres > Download for instructions on installing Postgres database.

psql --version

-or-

Install SQLite3

Visit Rails > Getting_started > Installing SQLite for instructions on installing SQlite database.

Create Project

Run rails new --help to view all command options.

Postgres + Bootstrap + Esbuild

Creates a new Rails project with Postgres database, Bootstrap css and ESbuild javascript.

rails new . -s --git --database=postgresql --css=bootstrap --javascript=esbuild

-or-

Postgres + Tailwind + Esbuild

Creates a new Rails project with Postgres database, Tailwind css and ESbuild javascript.

rails new . -s --git --database=postgresql --css=tailwind --javascript=esbuild

-or-

Postgres + Bootstrap + Webpack

Creates a new Rails project with Postgres database, Bootstrap css and Webpack javascript.

rails new . -s --git --database=postgresql --css=bootstrap --javascript=webpack

-or-

Postgres + Tailwind + Webpack

Creates a new Rails project with Postgres database, Tailwind css and Webpack javascript.

rails new . -s --git --database=postgresql --css=tailwind --javascript=webpack

-or-

Postgres + Bootstrap + Rollup

Creates a new Rails project with Postgres database, Bootstrap css and Rollup javascript.

rails new . -s --git --database=postgresql --css=bootstrap --javascript=rollup

-or-

Postgres + Tailwind + Rollup

Creates a new Rails project with Postgres database, Tailwind css and Rollup javascript.

rails new . -s --git --database=postgresql --css=tailwind --javascript=rollup

Migrate Database

After creating your Rails project, you'll need to run rails db:create to create the local database.

User Authentication

Setup authentication so that users can login to your application.

Setup Devise

Devise is flexible authentication solution for Rails with Warden.

This template adds user authentication to your app using the Devise gem.

  rails app:template LOCATION="https://railsbytes.com/script/X8Bsjx"

Installation Questions:

  • What do you want to call your Devise model? User
  • Do you want to any extra attributes to User? y
  • What attributes? name # use comma separated list of attributes

Post Installation Steps:

  1. In config/environments/development.rb, add config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
  2. Migrate Database:
rails db:migrate

Learning More:

User Authorization

Setup authorization so you can protect resources based on user roles.

Setup CanCanCan

CanCanCan is authorization Gem for Ruby on Rails.

This template add CanCanCan gem and generates default abilities file.

rails app:template LOCATION='https://railsbytes.com/script/V33sj3'

Learning More:

Single Sign On

Allows users the ability to login to your application through other services like Google.

Setup Omniauth

Omniauth is a flexible authentication system utilizing Rack middleware.

This template adds Omniauth gem, creates sessions, registrations and omniauth controllers

rails app:template LOCATION='https://railsbytes.com/script/xkjsK3'

Post Installation Steps:

  1. Add Omniauth routes to config/routes.rb
devise_for :users,
  controllers: {
    sessions: "sessions",
    registrations: "registrations",
    omniauth_callbacks: "omniauth",
  }

Learning More:

Soft Deletes

Provide soft delete functionality so you have ability to un-delete records.

Setup Paranoia

Paranoia provides soft deletes functionality to ActiveRecord.

This template installs the Paranoia gem for soft deletes.

rails app:template LOCATION='https://railsbytes.com/script/Xg8s3J'

Learning More:

-or-

Setup Discard

Discard, soft deletes for ActiveRecord done right.

This template installs the Discard gem for soft deletes.

rails app:template LOCATION='https://railsbytes.com/templates/z0gsEQ'

Learning More:

Image Uploads

Add file upload functionality to a cloud storage services.

Setup ActiveStorage

ActiveStorage facilitates uploading files to a cloud storage service like Amazon S3, Google Cloud Storage, or Microsoft Azure.

This template adds ActiveStorage to your Rails app.

rails app:template LOCATION='https://railsbytes.com/script/zJosLx'

-or-

Setup Shrine

Shrine is a modular file upload toolkit that allows direct uploads to Amazon S3, resumable uploads, image processing and more.

This template installs Shrine gem, config initializer, plus adds some handy uploaders you can use.

rails app:template LOCATION='https://railsbytes.com/script/xYasLK'

Project Configuration

Some handy project configurations to make your life simpler.

Setup Figaro

Figaro is simple Heroku-friendly configuration using ENV and a single YAML file.

This template adds Figaro for simple configuration using ENV and a single YAML file.

rails app:template LOCATION="https://railsbytes.com/script/VRZs9V"
Setup Rubocop

Rubocop is an extension focused on enforcing Rails best practices and coding conventions.

This template adds rubocop to your Rails app.

rails app:template LOCATION="https://railsbytes.com/script/XE5sl5"
Setup Better Errors

Foreman is better error page for Rack apps.

This template adds Better Errors and Binding of Caller gems.

rails app:template LOCATION="https://railsbytes.com/script/V33s0D"
Improve Seeds Folder

Organize your seeds files into environment folders and execute them in alphanumeric order.

This template sets up environment specific seeds folders.

rails app:template LOCATION='https://railsbytes.com/script/xGqsmL'
Clear Development Logs

Automatically clear development logs when they get over 2mb.

This template adds an initializer to clear development logs.

rails app:template LOCATION='https://railsbytes.com/script/VZgs77'
GitHub Issue Templates

Creates bug reports, feature requests and code maintenance issue templates in GitHub.

This template adds some handy GitHub issue templates.

rails app:template LOCATION='https://railsbytes.com/script/XvEs4K'
GitHub Pull Request Template

Creates a pull request template for GitHub.

This template add a GitHub pull request template.

rails app:template LOCATION='https://railsbytes.com/script/VdrsPl'

Git Aliases

Some handy git aliases I like to use to save time.

Git Add Commit Push

This alias does a git add, commit and push all on one line.

git config --global alias.add-commit-push '!git add -A && git commit -m "$1" && git push && git status'

You can use the add-commit-push alias like this.

git add-commit-push "Add, commit, push in one line!"
Git New Branch

This alias adds, commits and pushes current changes to a new branch.

git config --global alias.new-branch '!git checkout -b "$1" && git add -A && git commit -m "$2" && git push -u origin "$1" && git status'

You can use the new-branch alias like this.

git new-branch "123-my-branch" "Checkout, add, commit, push!"
Git New Tag

This alias creates a new tag and pushes it using the timestamp for naming.

git config --global alias.new-tag '!git tag -a -m `date +'%Y-%m-%d_%H-%M'` `date +'%Y-%m-%d_%H-%M'` && git push origin `date +'%Y-%m-%d_%H-%M'` && git status'

You can use the new-tag alias like this.

git new-tag

VS Code Extensions

Some handy extensions for Visual Studio Code.

Rails

Ruby on Rails support for Visual Studio Code

https://marketplace.visualstudio.com/items?itemName=bung87.rails

Ruby

This extension provides enhanced Ruby language and debugging support for Visual Studio Code

https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby

Ruby Language Colorization

Ruby Language Colorization for Visual Studio Code

https://marketplace.visualstudio.com/items?itemName=groksrc.ruby

Ruby on Rails

This extension for Visual Studio Code adds snippets for Ruby on rails.

https://marketplace.visualstudio.com/items?itemName=hridoy.rails-snippets

Ruby Solargraph

Solargraph is a language server that provides intellisense, code completion, and inline documentation for Ruby.

https://marketplace.visualstudio.com/items?itemName=castwide.solargraph

Simple Ruby ERB

This extensions tries to provide simple Ruby and ERB support to Visual Studio Code without messing with linting or debugging.

https://marketplace.visualstudio.com/items?itemName=vortizhe.simple-ruby-erb

VSCode Ruby

This extension provides improved syntax highlighting, language configuration, and snippets to Ruby and ERB files within Visual Studio Code.

https://marketplace.visualstudio.com/items?itemName=wingrunr21.vscode-ruby

Ruby Rubocop

This extension provides interfaces to rubocop for vscode.

https://marketplace.visualstudio.com/items?itemName=misogi.ruby-rubocop

Rails Templates

Visit railsbytes.com for other handy templates to help setup your project.

Rails Tutorials

If you are looking for Rails tutorials, I'd highly recommend you checkout gorails.com and driftingruby.com, both great resources for learning Rails.

About

A starter blueprint for fast tracking Rails development

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published