This is a Ruby on Rails with MySQL template, configured for quick development setup in Crafting Sandbox.
This template was created with MySQL and without Minitest:
rails new template-ruby-rails -d mysql -T
Rspec is used for testing instead:
gem 'rspec-rails', '~> 5.0.0'
Rubocop is used for linting, enforcing many of the guidelines outlined in the community Ruby Style Guide.
gem 'rubocop-rails', require: false
The shell script sandbox.sh
is used to configure sandbox for quick workspace setup. The manifest file .sandbox/manifest.yaml
uses it during build stage when creating a new sandbox using this template.
config/database.yml
is modified to use the preconfigured credentials set in App configuration. The environment variables MYSQL_SERVICE_HOST
and MYSQL_SERVICE_PORT
come already populated in sandbox.
This template comes with a Pings
controller already generated:
rails g controller Pings pong
whereby the action pong
is defined as:
def pong
@pong = {
ping: @ping.presence || "To ping, or not to ping...",
received_at: @current_time
}
render json: @pong
end
with the route:
get 'ping', to: 'pings#pong'
This action receives a parameter string, and responds with the param string and the current time. For example:
$ curl --request GET 'localhost:3000/ping?ping=hello'
{"ping":"hello","received_at":"XXXX-XX-XXXXX:XX:XX.XXXX"}
The following App Definition was used to create this template:
endpoints:
- name: api
http:
routes:
- pathPrefix: "/"
backend:
target: ruby-rails
port: api
authProxy:
disabled: true
workspaces:
- name: ruby-rails
description: Template backend using Ruby/Rails
ports:
- name: api
port: 3000
protocol: HTTP/TCP
checkouts:
- path: backend
repo:
git: https://github.com/crafting-dev/template-ruby-rails
packages:
- name: ruby
version: 2.7.2
- name: nodejs
version: 16.12.0
dependencies:
- name: mysql
serviceType: mysql
version: '8'
properties:
database: superhero
password: batman
username: brucewayne