なるようになるブログ

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

rails commit log流し読み(2015/01/04)

2015/01/04分のコミットです。

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

railties/CHANGELOG.md

before callback chainを停止させる条件がfalseをreturnする事から、throw(:abort)する事に変更するPRがマージされており、以下のCHANGELOGはすべてその変更に関するCHANGELOGです。その為、リンク先はすべて同じPRへのリンクになっています。

activemodel/CHANGELOG.md

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md

railties/CHANGELOG.md

callbackに関するCHANGELOGはここまで。ここからすべて、deprecateになっていたメソッド/クラスの削除、挙動の変更に関するCHANGELOGです。

activesupport/CHANGELOG.md

actionmailer/CHANGELOG.md

actionpack/CHANGELOG.md

actionview/CHANGELOG.md

activemodel/CHANGELOG.md

activerecord/CHANGELOG.md


Fix a few typos [ci skip]

コンポーネントのdocのタイポを修正しています。


Remove the tmp/sessions folder and its clear task

railties/lib/rails/commands/server.rbrailties/lib/rails/tasks/tmp.rake 及び各guideの修正です。

tmp/sessionsディレクトリを作成しないよう修正、及びtmp/sessionsディレクトリについての説明をraiils guideから削除しています。

session情報保持用に作ったと思われるのですが、現在使って無いので削除したとの事です。


Remove some warnings

railties/test/application/configuration_test.rbの修正です。

rails applicationを保持している変数名をapp -> applicationに修正しています。

warningsを取り除く為との事なので、変数名がバッティングした為ですかねえ。


Merge pull request #17227 from claudiob/explicitly-abort-callbacks

callback処理の修正です。before callback chainを停止させる条件がfalseをreturnする事から、throw(:abort)する事に変更になっています。

Rails 4.2までは、ActiveRecord, ActiveModel and ActiveModel::Validationsのbefore callback で呼ばれた処理の戻り値がfalseだった場合、callback chainを途中で停止するようになっていました。

class Post < ActiveRecord::Base
  before_save { |post| puts "Callback 1"; false }
  before_save { |post| puts "Callback 2" }
  after_save  { |post| puts "Callback 3" }
end

# Inside a new Rails 4.2 app
post = Post.new
post.save
# Callback 1
# => false

Rails 5.0以降ではこの挙動が代わり、falseをreturnしてもcallback chainが停止しないようになっています。

# Inside a new Rails 5.0 app
post = Post.new
post.save
# Callback 1
# Callback 2
# Callback 3
# => true

なお、上記は新規でapplicationを作成した場合のケースで、過去バージョンからのアップグレードの場合は、falseをreturnした場合にcallback chainを停止する挙動はそのままで、deprecationメッセージが表示されるようになります。

# Inside a Rails 4.2 app upgraded to Rails 5.0
post = Post.new
post.save
# Callback 1
# DEPRECATION WARNING: Returning `false` in a callback will not implicitly halt a callback chain in the next release of Rails. To explicitly halt a callback chain, please use `throw :abort` instead.
# => false

falseをreturnした場合に、callback chainを停止する/しないの挙動は、config.active_support.halt_callback_chains_on_return_falseで変化し、 throw :abortへの対応が完了したら、halt_callback_chains_on_return_falsefalseを設定してあげれはOKとの事です。


Update bug report templates to use version 4.2.0 instead of 5.0.0 [ci skip]

guides/bug_report_templates/action_controller_gem.rbguides/bug_report_templates/active_record_gem.rbの修正です。

railsのバージョンを5.0.0 -> 4.2.0に戻しています。リリースされているgemの最新のバージョンは4.2.0の為との事。


Remove deprecated ActiveSupport::Cache::Store.instrument

activesupport/lib/active_support/cache.rbの修正です。

deprecateになっていたActiveSupport::Cache::Store.instrumentメソッドを削除しています。


Remove deprecated core_ext/big_decimal/yaml_conversions file

deprecateになっていたactivesupport/lib/active_support/core_ext/big_decimal/yaml_conversions.rbを削除しています。


Remove deprecated methods at Kernel.

activesupport/lib/active_support/core_ext/kernel/reporting.rbの修正です。

deprecateになっていたKernel#silence_stderrKernel#silence_streamKernel#captureKernel#quietlyメソッドを削除しています。


Remove deprecated ActiveSupport::SafeBuffer#prepend

activesupport/lib/active_support/core_ext/string/output_safety.rbの修正です。

deprecateになっていたActiveSupport::SafeBuffer#prependメソッドを削除しています。


Remove deprecated ActiveSupport::JSON::Encoding.encode_big_decimal_as_string=

activesupport/lib/active_support/json/encoding.rbの修正です。

deprecateになっていたActiveSupport::JSON::Encoding.encode_big_decimal_as_stringメソッドを削除しています。


Remove deprecated ActiveSupport::JSON::Encoding::CircularReferenceError.

activesupport/lib/active_support/json/encoding.rbの修正です。

deprecateになっていたActiveSupport::JSON::Encoding::CircularReferenceErrorクラスを削除しています。


Change the default test order from :sorted to :random

activesupport/lib/active_support/test_case.rbの修正です。

test orderのデフォルトを:sortedから:randomに修正しています。


Remove deprecated ActionMailer deliver & deliver!

actionmailer/lib/action_mailer/message_delivery.rbの修正です。

deprecateになっていたMessageDelivery#deliverMessageDelivery#deliver!メソッドを削除しています。


Remove deprecated option use_route in controller tests

actionpack/lib/action_controller/test_case.rbの修正です。

deprecateになっていたcontrollerのテストでのuse_routeオプションを削除しています。


Remove deprecated ActionDispatch::Http::Parameters#symbolized_path_parameters

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

deprecateになっていたActionDispatch::Http::Parameters#symbolized_path_parametersメソッドを削除しています。


Remove deprecated ActionDispatch::Request#deep_munge

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

deprecateになっていたActionDispatch::Request#deep_mungeメソッドを削除しています。


Remove deprecated ActionDispatch::Response#to_ary

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

deprecatedになっていたActionDispatch::Response#to_aryメソッドを削除しています。


Remove deprecated support to define routes with :to option that

actionpack/lib/action_dispatch/routing/mapper.rbの修正です。

deprecateになっていた、routeのtoオプションに"#"を含まない値を設定された場合の処理を削除しています。


Remove deprecated NamedRouteCollection#helpers

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

NamedRouteCollection#helpersメソッドを削除しています。


Remove deprecate *_path helpers in email views

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

deprecateになっていたemailのviewで*_path helperメソッドを使用された場合の処理を削除しています。


Remove deprecated only_path option on *_path helpers

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

deprecateになっていた*_path helperメソッドonly_pathオプションを削除しています。


Remove deprecated usage of string keys in URL helpers

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

deprecateになっていたURL helperメソッドのkeyにStringクラスを使用した場合の処理を削除しています。


Remove deprecated assertion files

deprecateになっていた actionpack/lib/action_dispatch/testing/assertions/dom.rbactionpack/lib/action_dispatch/testing/assertions/selector.rbactionpack/lib/action_dispatch/testing/assertions/tag.rbを削除しています。


Remove deprecated AbstractController::Base::parent_prefixes

actionview/lib/action_view/view_paths.rbの修正です。

deprecateになっていたAbstractController::Base::parent_prefixesメソッドを削除しています。


Change the default template handler from ERB to Raw.

actionview/lib/action_view/template/handlers.rbの修正です。

default template handlerがERBからRawに変更になっています。拡張子の指定が無い場合、今後は"raw"ファイルとして処理が行われます。


Remove deprecated ActiveModel::Dirty#reset_#{attribute} and ActiveModel::Dirty#reset_changes.

deprecateになっていたActiveModel::Dirty#reset_#{attribute}ActiveModel::Dirty#reset_changesメソッドを削除しています。


Remove deprecated automatic counter caches on has_many :through

activerecord/lib/active_record/associations/has_many_through_association.rbの修正です。

deprecateになっていた、has_many :throughアソシエーションを使用している場合に自動でcounter cacheの値の更新を行う処理を削除しています。


Remove cache_attributes and friends

activerecord/lib/active_record/attribute_methods/read.rbの修正です。

deprecateになっていたcache_attributescached_attributes, cache_attribute?メソッドを削除しています。


Remove deprecated serialized_attributes

activerecord/lib/active_record/attribute_methods/serialization.rbの修正です。

deprecateになっていたserialized_attributesメソッドを削除しています。


Return a null column from column_for_attribute when no column exists.

activerecord/lib/active_record/associations/preloader/association.rbの修正です。

column_for_attributeの引数に存在しないカラムを指定した場合、ActiveRecord::ConnectionAdapters::NullColumnクラスを返すよう修正しています。


Return an array of pools from connection_pools

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

connection_poolsメソッドconnection_pool_listエイリアスとなりArrayを返すよう修正しています。


Change the default null value for timestamps to false activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rbの修正です。

schemaのtimestampsメソッドのデフォルトがnull: trueからnull: falseに変更になっています。


Remove deprecated access to connection specification using a string acessor.

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

deprecateになっていた、DBのconnection 定義をstring acessor経由で取得する処理を削除しています。


Remove deprecated ActiveRecord::Base.disable_implicit_join_references=

activerecord/lib/active_record/core.rbの修正です。

deprecateになっていたActiveRecord::Base.disable_implicit_join_references=メソッドを削除しています。


Remove deprecated ActiveRecord::Fixtures constant

activerecord/lib/active_record/fixtures.rbの修正です。

deprecateになっていたActiveRecord::Fixturesを削除しています。


Remove deprecated symbolized_base_class and symbolized_sti_name

activerecord/lib/active_record/inheritance.rbの修正です。

deprecateになっていたsymbolized_base_classsymbolized_sti_nameメソッドを削除しています。


Remove deprecated Reflection#source_macro

activerecord/lib/active_record/reflection.rbの修正です。

deprecateになっていたReflection#source_macroメソッドを削除しています。


Remove deprecated sanitize_sql_hash_for_conditions

activerecord/lib/active_record/sanitization.rbの修正です。

deprecateになっていたsanitize_sql_hash_for_conditionsメソッドを削除しています。


Change transaction callbacks to not swallowing errors.

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

deprecateになっていたActiveRecord::Base.errors_in_transactional_callbacks=メソッドの削除及び transaction callbacksでエラーがおきた際、エラーを握りつぶさないよう挙動を修正しています。


Change the behavior of boolean columns to be closer to Ruby's semantics.

activerecord/lib/active_record/type/boolean.rbの修正です。

boolean columnsの挙動をRubyの挙動に合わせるよう修正しています。

もともと、true値のリストを保持し、そこに値が一致した場合のみtrueと判定したのですが、今後は逆にfalse値のリストの判定のみ行い、一致しない場合trueとみなされるようになります。

具体的には、falseとみなされていた、' '、"\u3000\r\n"、"\u0000"、 'SOMETHING RANDOM' 等の値がtrueと判定される事になります。

因みに、falseとみなす値リストは以下の通りです。

[false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF']