なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2023/03/10)

2023/03/10分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activemodel/CHANGELOG.md


Enhance has_secure_password to also generate a password_salt method https://github.com/rails/rails/commit/ebe9e575b7691c6a04abfadfedfb55516eb63e47

activemodel/lib/active_model/secure_password.rbの修正です。

has_secure_passwordメソッドを使用している場合に、password digestの計算に使用する為のsaltを返す#{attribute}_saltを使用出来るよう修正しています。

class User < ActiveRecord::Base
  has_secure_password
  generates_token_for :password_reset, expires_in: 15.minutes do
    password_salt&.last(10)
  end
end

Use Thor for built-in secret task

railties/lib/rails/commands/secret/secret_command.rbrailties/lib/rails/tasks/misc.rakeの修正です。

secretコマンドを実装するのにrake taskを使用していたのを、Thorを使用するよう修正しています。


Define ActiveRecord::Base#id API for composite primary key models

Active Recordの修正です。

composite primary keyを使用している場合に、ActiveRecord::Base#idメソッドが全てのprimary keyのcolumnを返すよう修正しています。

class Order < ActiveRecord::Base
  self.primary_key = [:shop_id, :id]
end
order = Order.create!(shop_id: 1, id: 2)
order.id # => [1, 2]