なるようになるブログ

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

rails commit log流し読み(2015/03/23)

2015/03/23分のコミットです。

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

activesupport/CHANGELOG.md

activerecord/CHANGELOG.md


[ci skip] Add link for "parameter_names section"

rails guideのForm Helpersの修正です。

Binding a Form to an Objectの項、paramについて説明している箇所で、Understanding Parameter Naming Conventionsの項へのリンクを追加しています。


Change 'a' to 'an' for 'HABTM' word [ci skip]

rails guideのActive Record Migrationsの修正です。

a HABTM -> an HABTMにタイポを修正しています。


Deprecate alias_method_chain in favour of Module#prepend

ActiveSupportの修正です。

alias_method_chainメソッドがdeprecateになりました。代わりにRuby標準のModule#prependを使ってね、との事です。

ただ、Ruby 2.2.1には、ClassにModuleをprependするとSystemStackErrorが起きてしまうバグがあり、まだRails内の一部機能にalias_method_chainを使ってる状態になっています。


Move #19447 changelog to the top and reword it a bit [ci skip]

activerecord/CHANGELOG.mdの修正です。

Check subtype limit before using the default limitの対応をCHANGELOGの先頭に移動、及び微修正を行っています。


Merge pull request #19455 from jonatack/patch-1

rails guideのAction View Overviewの修正です。

Hashを使用する際、値の前後にスペースを入れるよう修正しています。

-  <%= render partial: "product", locals: {product: product} %>
+  <%= render partial: "product", locals: { product: product } %>

Fix ActiveModel::Errors#delete return value to stay backward compatible

activemodel/lib/active_model/errors.rbのdoc、及び activemodel/test/cases/errors_test.rbの修正です。

ActiveModel::Errors#deleteメソッドが削除した値を返すテストの追加、及びActiveModel::Errorsクラスのdocでdeprecateになったメソッドを使用していたのを、使用しないよう修正しています。


Fix arguments order on assertion

activemodel/test/cases/errors_test.rbの修正です。

先のコミットで追加されたテストで、assert_equalメソッドの引数の順番が間違えていた(actual、expectedの順番になっていた)のを修正しています。


Simplify setting button form options

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

button_toメソッドで、不要なHash#merge!メソッドの呼び出しを削除しています。


Make sure to persist a newly-nil serialized value

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

serialized hashの値を更新した場合、更新前の値が取得されてしまうバグがあったのを修正しています。

class User < ActiveRecord::Base
  serialize :user_meta, Hash
end

u = User.new
u.user_meta = {a_key: 'a_value'}
u.save # => true
u.reload.user_meta # => {a_key: 'a_value'}

u.user_meta.delete(:a_key)
u.user_meta # => {}
u.save # => true
u.reload.user_meta # => {a_key: 'a_value'}

Provide a more truthful #inspect

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

Serializedクラスにinspectメソッドを追加しています。

+      def inspect
+        Kernel.instance_method(:inspect).bind(self).call
+      end

デバッグ用ですね。


remove old unavailable link with relevant fix

各docの修正です。もう存在しないhttp://dev.rubyonrails.org/へのリンクが残っている箇所があったのを一通り修正しています。


update mysql link that has been replaced

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

MySQLへのリンク先に誤りがあったのを修正しています。


Remove reference to Numeric#from_now, as it is no longer supported

activesupport/lib/active_support/core_ext/integer/time.rbactivesupport/lib/active_support/core_ext/numeric/time.rbのdocの修正です。

もう存在しないNumeric#from_nowメソッドについての説明が残ってしまっていたのを削除しています。


Add documentation for Duration#to_i for clarification

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

Duration#to_iメソッドのdocを追加しています。


Fix ActionDispatch::PublicExceptions returning string rack status

actionpack/lib/action_dispatch/middleware/public_exceptions.rbの修正です。

callメソッドでrackからhttp statusを取得する際、integerに変換するよう修正しています。

-      status       = env["PATH_INFO"][1..-1]
+      status       = env["PATH_INFO"][1..-1].to_i

Fix failing tests for #19474

actionpack/test/controller/show_exceptions_test.rbの修正です。

先のhttp statusの変換処理の影響でコケてしまったテストがあったのを修正しています。