Skip to content

saturdaymp-examples/rails-6.0-template

Repository files navigation

Rails 6 Template

Status
GitHub
GitLab Gitlab pipeline status coverage report
Code Climate Maintainability
Linting Ruby Style Guide
Sponsorship GitHub Sponsors

A template for starting a new Rails applications. It includes:

Since it uses Docker the only thing you need installed on your development machine is Docker and your favorite Rails IDE. No need to install Ruby, Yarn, etc. Tested in my development environments of Ubuntu 18.04 LTS and Macos Mojave (10.14).

If you tried it and have any suggestions or imporvements please let know by opening an issue or pull request.

Development Environment Setup

Assuming you have Docker installed you get up and running by following the below steps:

  1. Click the "Use this Template" button. Alternativly you can just fork or download the of the repository to you local machine.

  2. In the repository root directly run the below command build the Docker container:

docker-compose build
  1. Run the continer. The Docker image base is Ruby Alpine Linux so we use sh instead of bash. Also when you first run this command it will pull down the Postgres Docker image.
docker-compose run web sh
  1. Create the database
rails db:create

5.) Start the Application

docker-compose up
  1. In a web browser navigate to http://localhost:3000 and you should see the home page.

I would also recommend running the following linter, typechecker, and unit tests. All the command should be run in the Docker container and should return no errors:

  1. RuboCop Standard linter:
rake standard
  1. Sorbet type checking:
srb tc
  1. Rails unit tests:
rails db:test:prepare
rails test

If you run into any issues or have any questions let me know by opening an issue.

RubyMine IDE Setup

Open up the project in RubyMine then navigate to the Settings->Languages & Frameworks->Ruby SDK and Gems. Then click the plus sign and add a new Remote Interperter. Choose Docker Compose with the following settings:

Server: Docker (create a new one if emtpy)
Configuration file(s): ./docker-compose.yml
Service: web
Environment variables: <leave blank>
Ruby of version manager path: ruby

Now you should be able to run/debug the application. If something is not working let me know by opening and issue.

Sorbet Init

If you run into an issue about libglib-2.0.so.0 when running srb init then you need to comment out the webdrivers gem in the Gemfile.

CI

There is a base GitLab automated build script and GitHub Actions script included in this template. It will build the docker image, run the Sorbet type checker, then run the tests. You can see the GitLab build in action here.

Why GitLab and GitHub? I use GitLab to store some of my private repos.