Modern Front-End Development for Rails - Bootstrapping

The introduction (page xii) says to download the code and run the bin/setup script, but the process wasn’t quite that one-click for me – that’s fine, it’s a beta book! But if you’re like me and want to dive into the fun parts, I thought I’d share the steps I used to get the introduction/01 Rails server up and showing the sample data. I hunted in the various files to find what versions of Ruby/Rails/JS/etc. the author is currently using:

postgres$ createuser --login -P nxns
Enter password for new role:
Enter it again:
postgres$ createdb -O nxns -U postgres nxns_development
postgres$ createdb -O nxns -U postgres nxns_test

$ rvm -v
rvm 1.29.6 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
$ rvm install 2.6.4
[...]
$ rvm use 2.6.4
Using /home/bjn/.rvm/gems/ruby-2.6.4
$ ruby -v
ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-linux]
$ nvm use 10.15.3   # see nrclient-code/introduction/06/.nvmrc
Now using node v10.15.3 (npm v6.4.1)
$ node -v
v10.15.3
$ yarn -v
1.22.4
$ cd nrclient-code/introduction/01
$ gem install bundler --conservative  # see bin/setup
[...]
$ bundle -v
Bundler version 2.1.4
$ bundle
[...]
$ bin/rails -v
Rails 6.0.0
$ grep -v '^ *#' config/database.yml | grep -v '^$'
default: &default
  adapter: postgresql
  encoding: unicode
  username: nxns
  password: <password-here>
  host: localhost
  port: 5432
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
  <<: *default
  database: nxns_development
test:
  <<: *default
  database: nxns_test
$ yarn install
[...]
$ RAILS_ENV=test rake db:migrate
$ bin/rails db:migrate
$ bin/rails db:seed
$ bin/rails s -b 0.0.0.0
2 Likes

Thanks! I do intend to clean this up on the next path through the book.

2 Likes