Skip to content

Commit

Permalink
Review and amend setting up a new Rails app
Browse files Browse the repository at this point in the history
This does a few minor updates to this document and replaces the linting
suggestion with a link to the document to configure linting.
  • Loading branch information
kevindew committed Nov 9, 2020
1 parent 9628a2c commit 134ad64
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions source/manual/setting-up-new-rails-app.html.md
Expand Up @@ -27,13 +27,13 @@ applications](/manual/conventions-for-rails-applications.html) and

To create a rails app, run the following (skip uncommon stuff).

```
```sh
rails new myapp --skip-javascript --skip-test --skip-bundle --skip-spring --skip-action-cable --skip-action-mailer --skip-active-storage
```

Replace the Gemfile with the gems you need. Here is an example.

```
```rb
source "https://rubygems.org"

gem "rails", "6.0.3.4"
Expand Down Expand Up @@ -65,10 +65,11 @@ end

Run `bundle && rails g rspec:install` and replace `spec/*helper.rb`.

```
## spec/rails_helper.rb
```sh
rm spec/rails_helper.rb
```

```rb
## spec/spec_helper.rb
ENV["RAILS_ENV"] ||= "test"

Expand All @@ -90,7 +91,7 @@ end

In config, replace the content of `database.yml` with the following.

```
```yaml
default: &default
adapter: postgresql
encoding: unicode
Expand All @@ -115,7 +116,7 @@ production:

In config, replace `credentials.yml.env` and `master.key` with `secrets.yml`.

```
```yaml
development:
secret_key_base: secret

Expand All @@ -128,23 +129,15 @@ production:

In config, replace the content of `routes.rb` with the following healthcheck.

```
```rb
Rails.application.routes.draw do
get "/healthcheck", to: proc { [200, {}, ["OK"]] }
get "/healthcheck", to: GovukHealthcheck.rack_response
end
```

Now is a good time to run `bin/setup`. Lastly, create `lib/tasks/lint.rake` with this.

```
desc "Lint files"
task "lint" do
sh "rubocop --format clang"
sh "scss-lint app/assets/stylesheets"
end
```

Then add `task default: %i(spec lint)` in Rakefile and finally run `rake`.
Now is a good time to run `bin/setup`. Lastly, to ensure your application has
beautiful consistent code, you should finish up by
[configuring linting](/manual/configure-linting.html) for it.

## Add a software licence

Expand Down Expand Up @@ -187,7 +180,7 @@ We have a common structure that is used for GOV.UK apps. Fill in some basic
details to get started with your app and flesh it out further as your project
develops.

```
```markdown
# App Name

One paragraph description and purpose.
Expand Down

0 comments on commit 134ad64

Please sign in to comment.