Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/infinum/default_rails_template
Default template for generating new Rails applications.
https://github.com/infinum/default_rails_template
ruby
Last synced: about 1 month ago
JSON representation
Default template for generating new Rails applications.
- Host: GitHub
- URL: https://github.com/infinum/default_rails_template
- Owner: infinum
- Created: 2016-11-08T11:04:41.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-03T16:12:52.000Z (11 months ago)
- Last Synced: 2024-04-13T23:11:56.182Z (5 months ago)
- Topics: ruby
- Language: Ruby
- Homepage:
- Size: 194 KB
- Stars: 28
- Watchers: 13
- Forks: 3
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Rails Default Template
The [Infinum](infinum.com) default template for generating new Rails applications.
## Requirements
Install the latest ruby version and set it as global
If you installed rbenv through homebrew:
```shell
brew upgrade ruby-build
```If you installed rbenv with git:
```shell
cd "$(rbenv root)"/plugins/ruby-build && git pull
```then run if needed:
```shell
rbenv install #{latest_ruby}
rbenv global #{latest_ruby}
```### GitHub Actions
This template uses GitHub Actions for CI/CD. In order for workflows to work properly some [secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) have to be set up.
For build workflow to work, the following secrets must exist (usually set up by DevOps):
- `VAULT_ADDR`
- `VAULT_AUTH_METHOD`
- `VAULT_AUTH_ROLE_ID`
- `VAULT_AUTH_SECRET_ID`For deploy workflows, you need to generate private/public SSH key pairs for each environment. Public key should be added to the server to which you're deploying. Private key should be added as a secret to GitHub and named `SSH_PRIVATE_KEY_#{ENVIRONMENT}`, where `ENVIRONMENT` is replaced with an appropriate environment name (`STAGING`, `PRODUCTION`, etc.).
#### Slack notifications
Build and deploy workflows can send Slack notifications upon completion of workflow runs. To enable this, add the following to the workflow:
- `SLACK_BOT_TOKEN` secret (you should already have this GitHub secret set up in the repo)
- `slack_notification_channel` input with the name of the Slack channel as the value (without the # symbol)By default, a notification will be sent if the run either succeeded or failed. If you want notifications only on successful runs, add the `notify_on` input to the workflow with the value `success`. Similarily, if you want notifications only for failed runs, the value of the `notify_on` input should be `failure`.
### Frontend
If your application will have a frontend (the template will ask you that), you must have Node installed on your machine. The template creates a `.node-version` file with the Node version set to the version you're currently running (check by executing `node -v`). Therefore, ensure that you have the latest [Active LTS](https://nodejs.org/en/about/releases/) version of Node running on your machine before using the template.
## Usage
```shell
rails new myapp --database=postgresql -T -B -m https://raw.githubusercontent.com/infinum/default_rails_template/master/template.rb
```
The `-T` flag skips minitest files.The `-B` flag skips the second bundle install.
The `-m` flag tells the generator to run our app [template](https://github.com/infinum/default_rails_template/blob/master/template.rb).
## What does this template do?
- Updates the README.md file
- Creates bin/setup and bin/update scripts
- Creates a `config/environments/staging.rb` file
- Updates the `config/environments/development.rb` file
- Creates a [Bugsnag](https://bugsnag.com) initializer
- Removes gems we never use: `coffee-rails`, `jbuilder`, `tzinfo-data` & `byebug`
- Adds [Bugsnag](https://github.com/bugsnag/bugsnag-ruby) & [Figaro](https://github.com/laserlemon/figaro) to the Gemfile
- Adds [Pry-Rails](https://github.com/rweng/pry-rails) to the Gemfile, inside of the development and test group
- Adds [Rubocop](https://github.com/bbatsov/rubocop), [RSpec-Rubocop](https://github.com/backus/rubocop-rspec) & [Overcommit](https://github.com/brigade/overcommit) to the Gemfile, inside of the development group
- Adds [Rspec-Rails](https://github.com/rspec/rspec-rails) to the Gemfile and initializes it
- Initializes deploy script with [Mina](https://github.com/mina-deploy/mina)
- Initializes spring binstubs
- Updates the secrets.yml file to use Figaro and have defaults
- Creates a `config/application.yml` file for Figaro
- Creates a `.rubocop.yml` file with our defaults
- Git inits
- Adds more common gitignored files to `.gitignore`
- Adds documentation in `docs` folders## Recommendations
After running the template generator, this script will install overcommit which won't let you commit your project if it has some Rubocop offenses or if your Gemfile isn't alphabetically sorted. To sort your Gemfile, use the [Eefgilm](https://github.com/enilsen16/Eefgilm) gem. Install it with `gem install eefgilm` and run the `eefgilm` command to sort your Gemfile.
## Filling up the documentation
Here is an example of line inside documentation:
```
* ACCOUNT-NAME (ACCOUNT-ID)
```
The first comment is an example of how to fill the data on the leftThe second comment is who can fill this information. It can be either DEVOPS or DEVELOPER. If you as a DEVELOPER have access to a specific information, you can also fill up DEVOPS lines (for example, if you have access to AWS console, most of the information in server documenation can be filed by a developer).
## Development
There are a couple of helpers you can use when developing:
``` ruby
ask_with_default # Presents a user with a question he can answer. Returns default if user does not enter anything
yes? # Ask a user yes/no question. Returns true/false
```