Rails Tutorial 第3版 第7章

Ruby on Rails チュートリアル:実例を使って Rails を学ぼう の2周目です。
第7章 ユーザー登録 | Rails チュートリアル

第7章 ユーザー登録

メインはユーザ登録にまつわる、form関連のお話です。
ようやくwebアプリっぽくなってきました。
以下、その他気になったところ。

debugger

bybug によるdebuggerの使い方。
web-console すごいです。

console での Helperの利用方法

include ActionView::Helpers::TextHelper

assert_no_difference, assert_difference

実行後の件数チェックするテスト。
非常に便利ですね。

assert_no_difference 'User.count' do
  post users_path, user: { name:  "",
                           email: "user@invalid",
                           password:              "foo",
                           password_confirmation: "bar" }
end

ssl

config.force_ssl = true

pumaの利用

pumaはほとんど扱ったことなかったので、勉強になりました。
config/puma.rb

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/
  # deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection
end

./Procfile

web: bundle exec puma -C config/puma.rb