Skip to content

roonyx-tech/rails-starter

Repository files navigation

About

Rails Starter Kit was created as a way to save time when starting a new Rails project. We have taken the most common functionality and configuration in our existing Rails projects, and put those into this project. Simply clone this project, and change the git remote to your remote repository. Rails Starter Kit is ready to start with docker-compose.

Table of contents

Out-of-the-box functionality

Getting started

Requirements:

  • Ruby >= 3.0.2

Init

  1. Clone Rails Starter Kit
  2. Execute bundle && rails g rename:into YourAppName
  3. Go to ./../YourAppName
  4. Create a new repository on GitHub, BitBucket, or your own server
  5. Change the git remote to your new repository
  6. Push changes

Docker build

make setup

Run app

docker-compose up

Down app

docker-compose down

Docker

Migrate

make migrate

Rollback

make rollback

Bundle

make bundle

Reset database

make reset

rails console

make console

Run custom command

docker-compose run --rm rails bundle exec <your_custom_command>

Tests, Lints, Docs

Ci task

  • To run the CI task run:
rake ci

Running tests

  • To run the test suite simply run:
rspec

JSON context in rspec

  • Setup json helper in your spec file
include_context :json
  • And easy use json in expect
expect(json).not_to eq []

Running lints

  • To run rubocop lint
rubocop
  • Auto correct rubocop lint
rubocop -a

Generate docs

rake docs:generate

Coverage report

After call rspec will be in the ./coverage folder

Additional functionality

Application Service

Service objects are Plain Old Ruby Objects (PORO) that are designed to execute one single action in your domain logic and do it well.

  • Example service object
class ExampleService < ApplicationService
  attr_reader :name
  
  def initialize(name)
    @name = name
  end
  
  def call
    puts "Hello #{name}"
  end
end
  • For call object
ExampleService.call('name')

Debug

Setup byebug in your code, then attach to running container:

docker attach [rails_container_id]
  • Ctrl+D to the next point
  • continue to finish debug
  • Ctrl+P then Ctrl+Q to detach container

License

License: MIT