なるようになるブログ

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

rails commit log流し読み(2014/09/14)

2014/09/14分のコミットです。

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

activesupport/CHANGELOG.md

activerecord/CHANGELOG.md


use allow_blank option instead

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

passwordの空チェックにif: ->{ password.present? }を使用していたのを、allow_blank: trueに修正しています。


Revert "Merge pull request #15312 from JuanitoFatas/action_view/asset_path"

こちらのコミットをrevertしています。

asset_pathメソッドで引数のsourceをStringへ変換する前に空チェックを行うよう修正していたのですが、これによりPaperClipが動作しないバグが起きてしまった為、revertしています。

詳細はissue参照。


Merge pull request #13656 from chanks/rollback_transactions_in_killed_threads

activerecord/lib/active_record/connection_adapters/abstract/transaction.rbの修正です。

Transaction処理を行っているスレッドが、途中で死んた場合に、処理をrollbackするよう対応した、との事です。

ちょっと長いですが、テストコードから抜粋。

queue = Queue.new
thread = Thread.new do
  Topic.transaction do
    @first.approved  = true
    @second.approved = false
    @first.save

    queue.push nil
    sleep

    @second.save
  end
end

queue.pop
thread.kill
thread.join

assert @first.approved?, "First should still be changed in the objects"
assert !@second.approved?, "Second should still be changed in the objects"

assert !Topic.find(1).approved?, "First shouldn't have been approved"
assert Topic.find(2).approved?, "Second should still be approved"

なお、この対応はRuby 2.0+以上でのみ有効で、Ruby 1.9系はまだ未対応との事です。難しい…。


Time#change can now change nanoseconds (:nsec)

activesupport/lib/active_support/core_ext/time/calculations.rbの修正です。

Time#changeメソッドでnanosecondsについても変更出来るよう対応しています。

Time.local(2005,1,2,11,22,33,2).change(nsec: 8000)

Rescue Rack::Utils::ParameterTypeError instead of TypeError

actionpack/lib/action_dispatch/http/request.rbの修正です。

session_options=メソッドTypeErrorをrescueしていたのを、Rack::Utils::ParameterTypeErrorをrescueするよう修正しています。

rack側がRack::Utils::ParameterTypeErrorをthrowするようになっていたので、それに合わせた形のようです。