Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.
/ rails_base Public archive

This repository serves as a base repository for new projects in rails that we build at Drabkirn

License

Notifications You must be signed in to change notification settings

drabkirn/rails_base

Drabkirn Rails Base

This repository serves as a base repository for new projects in rails that we build at Drabkirn

Ruby 2.7.1 Rails 6.0.3.1 Rspec 4.0 Issues Issues closed Pulls Pulls License CLA assistant

We don't like building up the same rails project that we spin up for each new project that we build. So we made this template, where the defaults are set so we can prototype our ideas as fast as we can, then build the big picture of the project.



Table of Contents



Steps Taken:

  1. Basic Setup:

    • New Rails Application:
      $ rails new bare_rails -d mysql
    • Adding the .github folder for Issues and Pull request templates.
    • Adding the License, Code of conduct and contributing guidelines.
    • Updating the README.md for basic steps and README updates along the way.
    • Cleaning the Gemfile, update it and then run:
      $ bundle i
    • Added badges to the README file.
  2. Adding Testing support:

    • Added latest versions of brakeman, bundler-audit, database_cleaner, simplecov, shoulda-matchers, rails-controller-testing, rspec-rails, factory_bot_rails, faker. Then run:
      $ bundle i
    • Install Rspec:
      $ rails g rspec:install
    • Add --format documentation to .rspec
    • Rails generators - Not to run helpers generators in rails g command. See comment Don't run un-required generations of files in config/application.rb and uncomment required stuff as required.
    • In spec/rails_helper.rb - Added Simplecov, database cleaner, shoulda-matchers and FactoryBot:
      # Simple Cov
      ...
      
      # DB Cleaner
      ...
      
      # Shoulda Matchers
      ...
      
      # Include Factory Girl syntax to simplify calls to factories
      ...
  3. Environment variables and Database support:

    • Added the figaro gem and installed it with:
      $ bundle exec figaro install
    • Setting up the config/application-sample.yml with initial data.
    • Rewriting config/database.yml file to use config variables from figaro env variables.


Installation

  1. You must have Ruby version 2.6.5 and Rails 6.0.2 installed. You can install them using GoRails Setup Guide.

    • You can install Rails 6.0.2 with:
      $ gem install rails -v 6.0.2
    • This repo uses MySQL as it's database. You can install it from above GoRails guide.
    • That's it, prequisites are now installed.
  2. Clone the Repo:

    $ git clone https://github.com/drabkirn/rails_base.git
  3. Install dependencies:

    $ cd rails_base
    $ bundle i
    $ yarn install --check-files
  4. Rails Crendentials setup:

    • There is a config/credentials.yml.enc file, but this repo doesn't have the master.key, so delete this file:
      $ rm config/credentials.yml.enc
    • Create your new rails credentials:
      $ EDITOR=nano rails credentials:edit
    • Then press ctrl + X, then press Y and then press Enter to exit the nano editor. You don't have to change anything in your credentials, as we use figaro gem for our credentials. Rails credentials is only needed for secret_key_base
  5. Setting up figaro and Database setup:

    • Copy the config/application-sample.yml to config/application.yml
      $ cp config/application-sample.yml config/application.yml
    • Then in your config/application.yml, add all your database configuration. For example:
      development:
        db_hostname: "localhost"
        db_username: "root"
        db_password: "12345678"
        db_name: "flowers_app_development"
    • Then setup the database:
      $ rails db:create
      $ rails db:migrate
  6. Change the name of the Rails App:

    • Let's say your project name is flowers_app.
    • First, rename this folder from rails_base to flowers_app
    • Then, in config/application.rb, change Line 9 from module RailsBase to FlowersApp.
      • Remember the app name must be in PascalCase like above.
    • In package.json, change the name to:
      "name": "flowers_app",
    • In config/cable.yml, change channel_prefix: rails_base_production to:
      channel_prefix: flowers_app_production
    • In CONTRIBUTING.md and README.md file, change all references of https://github.com/drabkirn/rails_base to your own GitHub project. You can do this by finding the https://github.com/drabkirn/rails_base in these files and replacing it with your repo.
      • Also change all references of Drabkirn Rails Base or Rails Base to your app name.
  7. Test it:

    • Run the rails server:
      $ rails server
    • Now visit http://localhost:3000 and you should see default Rails page.
  8. Next steps:

    • Now you can proceed build your app.
    • If you want to use React(or any other JS library) as front-end, then:
      • you'll need to disable rails generations of assets and templates in config/application.rb. Just un-comment below lines:
        g.assets false
        g.template_engine false
      • Run the command:
        $ rails webpacker:install:react
      • Then build your front-end in app/javascript folder.
    • You can start by running a scaffold:
      $ rails g scaffold Artile title:string body:text
    • Then Consider writing tests in spec folder.
    • Add some more badges to your README.md file.


Contributing

If you would like to contribute, please check this contributing guide

Please check this Code of Conduct guide before contributing or having any kind of discussion(issues, pull requests etc.) with the Bare Rails project!


Connect:

Need any help? Have any Questions? Or just say us hi!

  1. Drabkirn Website
  2. Our Blog
  3. Discord Server
  4. Twitter
  5. Instagram

Releases

No releases published

Packages

No packages published