/rails_project_template

Custom template for basic Rails applications

Primary LanguageRuby

Sample Rails Project Template

This repo is to be used as a template for Rails projects. This includes gems and associated configurations commonly used in most Rails projects.

For additional information on the setup process that this repo was generated by, please see this gist.

Usage

  • Clone the project with your desired project name
git clone git@github.com:ryanflach/rails_project_template.git <your-project-name>
  • cd into the project directory
cd <your-project-name>
  • Remove the existing git repository
rm -rf .git
  • Initialize a new git repository
git init
  • Create your project on GitHub
hub create
  • Bundle
bundle
  • Install Figaro
bundle exec figaro install
  • Update the database names in config/database.yml
development:
  <<: *default
  database: <your_project_name>_development

test:
  <<: *default
  database: <your_project_name>_test

production:
  <<: *default
  database: <your_project_name>_production
  username: <your_project_name>
  password: <%= ENV['<YOUR_PROJECT_NAME>_DATABASE_PASSWORD'] %>
  • Initialize the database
bundle exec rake db:{create,migrate}
  • Update this README

Additional Common Configuration

Should your project need to work with an external API, you will want to add the following:

  • In your Gemfile:

    • Available to all environments:
      • gem 'faraday' - for making http requests (docs)
    • Under group :test
      • gem 'vcr' - for stubbing (docs)
      • gem 'webmock' - for mocking (used by VCR)(docs)
  • To make these gems available:

bundle
  • Add configuration in spec/rails_helper.rb:
require 'vcr'
VCR.configure do |config|
  config.cassette_library_dir = "spec/vcr_cassettes"
  config.hook_into :webmock
end
  • In .gitignore, ignore the cassettes that will be made:
# Ignore vcr cassettes
/spec/vcr_cassettes