なるようになるブログ

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

rails commit log流し読み(2014/10/16)

2014/10/16分のコミットです。

CHANGELOGへの追加はありませんでした。


Remove duplicate stringify_keys in text_field_tag

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

text_field_tagメソッドを使用する際、呼び出し元でstringify_keysメソッドを使用して、hashのkeyをStringクラスに変換していたのですが、text_field_tagメソッドの中でもstringify_keysを使用しており、重複しているので、呼び出し元の方のstringify_keysメソッドを削除しています。


Fix how file_ and password_field_tag edit options

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

file_field_tagpassword_field_tagメソッドで、引数のoptions値を追加する際に、updateメソッドを使用していたのをmergeメソッドを使用するよう修正しています。

Hash#updateだと、selfが変更されてしまうので、以下のように同じオプションを使い回そうとした際に、optionsfile_field_tagの中で設定した値が反映されてしまうバグがあったようです。

<% options = {class: 'important'} %>
<%= file_field_tag 'Upload', options %>
<%= text_field_tag 'Name', options %>

Merge pull request #17267 from rebyn/master

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

has_one associationsに対してthroughオプションを使用していて、そのthrough先で polymorphicを使用していた場合に不適切なエラーメッセージが表示されていたのを対応しています。ややこしい…。


Use if/else instead of early raise

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

early raiseの代わりに、if/elseを使用するよう修正しています。

-          raise HasOneAssociationPolymorphicThroughError.new(active_record.name, self) if has_one?
-          raise HasManyThroughAssociationPolymorphicThroughError.new(active_record.name, self)
+          if has_one?
+            raise HasOneAssociationPolymorphicThroughError.new(active_record.name, self)
+          else
+            raise HasManyThroughAssociationPolymorphicThroughError.new(active_record.name, self)
+          end

Fix typo in actionpack/lib/action_dispatch/routing/mapper.rb

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

HtttpHelpersHttpHelpersに修正しています。


add table.bigint support

activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rbactiverecord/lib/active_record/connection_adapters/postgresql_adapter.rbの修正です。

schema_definitionsにbigint対応を行っています。

create_table(:foos) do |t|
  t.bigint :hi
end

just look up the primary key from the columns hash

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

primary keyを検索する際、columnsメソッド経由で値を検索していたのを、@columns_hashから値を検索するよう修正しています。


we don't need a HWIA and a hash allocated for just one k/v pair

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

aliased_typesメソッドHashWithIndifferentAccessクラスで変換用の値を定義していたのですが、一つのkey/valueペアの為に、HashWithIndifferentAccessクラスを生成する必要は無いだろうという事で、処理を修正しています。

-        type = aliased_types[type] || type
+        type = aliased_types(type.to_s, type)
-      def aliased_types
-        HashWithIndifferentAccess.new(
-          timestamp: :datetime,
-        )
+      def aliased_types(name, fallback)
+        'timestamp' == name ? :datetime : fallback
       end

修正後の方が解りやすいですねえ。


clarify debugger platform invocation

railties/lib/rails/generators/rails/app/templates/Gemfileの修正です。

byebugについての説明を追加しています。


use require_command! instead of calling its definition

railties/lib/rails/commands/commands_tasks.rbの修正です。

各コマンド用のクラスをrequireする際、require_command!メソッドを使用するよう修正しています。

-        require "rails/commands/#{command}"
+        require_command!(command)

因みに、require_command!は、require "rails/commands/#{command}"を実行するだけなので、処理自体は変わってないでようです。


remove unneeded file

railties/lib/rails/commands/update.rbを削除しています。


some changelog formatting. [ci skip]

各モジュールのCHANGELOGの修正です。

シングルコーテーションを追加したり、スペース追加したり等フォーマットの修正を行っています。


[ci skip] add AC::InvalidCrossOriginRequest to list of rescue_responses default

rails guideのconfiguringの修正です。

rescue_responsesのデフォルトの設定の一覧にInvalidCrossOriginRequestを追加しています。


docs, since #16702 we detect mutation on serialized attributes. [ci skip]

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

serialized attributesについて、現状の仕様とあってない説明を削除しています。


pg, test assigning non-array values to an array column. Closes #14716.

activerecord/test/cases/adapters/postgresql/array_test.rbの修正です。

PostgreSQLのArray型のカラムに、Arrayじゃない値を設定した場合のテストを追加しています。

4.1より前の場合は、自動でArrayに変換していたらしいのですが、4.1からは変換しなくなっているので、その確認の為にテストを追加したようです。


test, better describe SerializationTypeMismatch behavior. refs #14716.

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

SerializationTypeMismatchについて、説明を修正しています。


mention the :without option [ci skip]

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

format validatorの説明の箇所に、withoutオプションについての説明を追加しています。


test, Generators::GeneratedAttribute with references, required, index.

railties/test/generators/generated_attribute_test.rbの修正です。

Generators::GeneratedAttributeにreferences、required、indexを合わせて指定した場合のテストを追加しています。