2015/07/21分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Correctly ignore
mark_for_destruction
withoutautosave
- Deprecate and rename the keys for association restrict_dependent_destroy
- Extra caller details added to ActiveRecord::RecordNotFound
Correctly ignore mark_for_destruction
without autosave
activerecord/lib/active_record/autosave_association.rb
の修正です。
mark_for_destruction
はautosave
オプションにtrue
が設定されている場合のみ動作する、とドキュメントに記載してあるのですが、実際はautosave
オプションの値に関わらずmark_for_destruction
が動作してしまっていました。autosave
が設定されてない場合は動作しないよう修正しています。
Fix state being carried over from previous transaction
activerecord/lib/active_record/transactions.rb
の修正です。
new_record?
メソッドが、新規レコードではないのにtrue
を返してしまうバグがあったのを修正しています。
例。name
アトリビュートが必須パラメータという場合。
# before author = Author.create! name: 'foo' author.name = nil author.save # => false author.new_record? # => true # after author = Author.create! name: 'foo' author.name = nil author.save # => false author.new_record? # => false
Transactions
モジュールのwith_transaction_returning_status
メソッドで最終のtransaction statusをちゃんと返せていなかったのが問題だったようです。
activerecord/test/cases/attributes_test.rb
の修正です。
array型のテストのテスト名にタイポがあったのを修正しています
Fix minor typo in testing guide
rails guideのA Guide to Testing Rails Applications
の修正です。
Taking it further
の項、editting
-> editing
にタイポを修正しています。
Ensure that microsecond precision is only used for version of mysql that support it. Fixes #19711
ActiveRecordのconnection adapterの修正です。
MySQLではmicrosecond precisionが使えるようになったのはv5.6.4 以降なのですが、Rails内部ではminorバージョンまでのチェックしかしておらず、 v5.6.3でエラーになってしまっていた為patchバージョンもチェックするよう修正しています。
同様に、indexのrename機能が使えるかどうかのチェックも厳密に行うよう修正しています。
railties/lib/rails/generators/erb/scaffold/templates/index.html.erb
の修正です。
generatorがデフォルトで生成するindex.html.erb
の新規ページ作成用リンクのテキストをhuman_name
からsingular_table_name.titleize
を使用するよう修正しています。
他のページではsingular_table_name.titleize
を使用するようになっており、合わせる為にこちらも変更したとの事です。
Merge pull request #20751 from repinel/remove-unnecessary-dup
actionpack/lib/action_dispatch/routing/mapper.rb
の修正です。
Mapper#add_route
メソッドから、不要なaction
のdup
処理を削除しています。
action
のdupを行っていたものの、移行の処理で、値が変更してからは参照される事が無い為、別にdupする必要性は無いだろう、という事で削除されたようです。
Deprecate and rename the keys for association restrict_dependent_destroy https://github.com/rails/rails/commit/b184398b5359da5b76367aa61551d0f3d7e99fc5
activerecord/lib/active_record/associations/has_many_association.rb
、
activerecord/lib/active_record/associations/has_one_association.rb
の修正です。
依存しているレコードがある為にレコードが削除出来ない場合に表示されるエラーメッセージのi18nのキーが、
元々restrict_dependent_destroy.one
、restrict_dependent_destroy.many
だったのを、それぞれ、
restrict_dependent_destroy.has_one
、restrict_dependent_destroy.has_many
に修正しています。 古いkeyを使用した場合、deprecateメッセージが表示されます。Rails 5.1で削除予定。
one
、many
はそれぞれi18n内で特別意味を持つ単語の為、キーに使用するのは良くない、という事で変更になったようです。
Merge pull request #20819 from y-yagi/rails_api_gemfile
railties/lib/rails/generators/rails/app/templates/Gemfile
の修正です。
Rails APIの場合、デフォルトで生成されるGemfileにweb-console
が記載されないよう修正しています。
Rails APIの場合viewが無いので、web-console
は不要だろう、という事で対応しています。
Merge pull request #20926 from rsanheim/fail-fast-bin-setup
railties/lib/rails/generators/rails/app/templates/bin/setup
の修正です。
bin/setup
コマンドに、system
が失敗した場合に即時にabortするsystem!
メソッドを定義して、各コマンドの実行にそのメソッドを使用するよう修正しています。
各コマンド実行時に、即処理が終了した方が良いだろう、との事で修正したとの事です。
Extra caller details added to ActiveRecord::RecordNotFound
activerecord/lib/active_record/core.rb
、
activerecord/lib/active_record/errors.rb
の修正です。
ActiveRecord::RecordNotFound
クラスに、エラーが発生した際のmodel名、primary_key、idが保持するよう修正しています。
これにより、RecordNotFound
が発生したmodel/idによって処理を分岐する、という事が出来るようになっています。例。
class SomeAbstractController < ActionController::Base rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404 private def redirect_to_404(e) return redirect_to(posts_url) if e.model == 'Post' raise end end