なるようになるブログ

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

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

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

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

actionpack/CHANGELOG.md

activerecord/CHANGELOG.md

activemodel/CHANGELOG.md


Introduce an Attribute object to handle the type casting dance

ActiveRecordの修正です。

ActiveRecord::Attributeクラスを新規に作成して、type castに関する処理を移動しています。まだまだ対応中の模様。


Ensure we always define attribute methods

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

initializeself.class.define_attribute_methodsを追加して、必ずattribute methodsが定義されるようにしています。


Specifically talking about Rake the library [ci skip]

activerecord/lib/active_record/tasks/database_tasks.rbのdocの酒精です。

接続詞を修正しています。


Add links to RDoc back into API documentation guidelines [ci skip]

rails guideのAPI Documentation Guidelinesの修正です。

RDocについてのリンクを追加しています。元々あったものが、間違いで消されてしまったようで、復旧しています。


Builder source code is still available on github [ci skip]

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

builderへのリンクを追加しています。


[ci skip] Clarify ActiveModel::Model docs

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

ActiveModelのattributesの実行結果の例がIntegerになっていたのですが、戻り値はStringなので、実行結果をStringに修正しています。

-  #   person.name # => 'bob'
-  #   person.age  # => 18
+  #   person.name # => "bob"
+  #   person.age  # => "18"

Document behavior concerns regarding the full Rails stack [ci skip]

rails guideのAPI Documentation Guidelinesの修正です。

Regarding the Rails Stackの項を追加しています。

class 又はメソッドのdocを作成する際、scope / contextを意識して下さい、という事かと。

例として、ActionView::Helpers::AssetTagHelper#image_tagメソッドが挙げられています。


ActionController::Parameters#require now accepts FalseClass values

ActionController::Parameters#requireメソッドがFalseClassの値も受け取る修正しています。

# before
  ActionController::Parameters.new({discount:false}).require(:discount)
  # ActionController::ParameterMissing: param is missing or the value is empty: discount

# after
  ActionController::Parameters.new({discount:false}).require(:discount)
  # false

元々、文字列のfalseは受け付けていたんですねえ。


Copy edits and code font wrap for Active Record [ci skip]

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

元々は<tt>でコードで等幅フォントを行っていたのを、+記号に修正しています。RDoc的には+でOKですね。


Copy edits from e0f3f1a [ci skip]

rails guideのAPI Documentation Guidelinesの修正です。

先ほど作成したRegarding the Rails Stackの項について、指摘を受けて箇所について微修正を行っています。


Create 4.2 release notes guide scaffold [ci skip]

guides/source/4_2_release_notes.mdの叩きの作成です。 Major Featuresの記載はまだのもよう。


First pass at Rails 4.2 release notes [ci skip]

guides/source/4_2_release_notes.mdの修正です。

RemoveDeprecateに修正しています。


Remove unused column types override

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

使用していない@column_types_overrideを削除しています。


Revert code changes at "Copy edits and code font wrap for Active Record [ci skip]"

先にあったactiverecord/lib/active_record/errors.rbのdocの修正で、全然関係無い実装処理をいじってしまったらしく、その部分だけrevertしています。


Reorder test which does not represent real world usage

activerecord/test/cases/attribute_methods_test.rbの修正です。

クラス定義した後にインスタンス生成するよう、処理の順番を修正しています。

real world usageは、まあ、確かにそうですよね。


In actionview, eliminate calls to tag that use html_safe parameter values. This is generally unnecessary, since tag handles string quoting, except in one case (utf8_enforcer_tag) where we want to specify the encoding ourselves.

ActionViewの修正です。

rendermail_toメソッドからhtml_safe処理を削除しています。

コミットログに記載された理由は下記の通りです。

  1. Your code should have access to the actual string value of any parameter, not the encoded version.
  2. You should not care about the exact encoding as HTML.
  3. Thinking about how to safely encode strings is hard, and tag already does a fine job.

1はまあその通りかなーとは思うのですが…。むう。最終的に、3の理由が大きいんですかねえ。


Reword PreparedStatementInvalid example, and use values instead of

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

説明をちょっと修正しています。


s/variable supplied/value supplied [ci skip]

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

コミットログの通りで、variable suppliedvalue suppliedに置換しています。


Remove unused method_missing definition

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

使用していないmethod_missingメソッドを削除しています。

method_missingが起きる事は無いから、との事です。


Detect in-place changes on mutable AR attributes

ActiveRecordの修正です。

mutable types(Serialized, JSON, HStore)を使用しているとき、attributesが変更された際に正しく検知が出来ていなかったのを修正しています。

ActiveModel::Dirtyで値が変更があったかどうか検知出来るのですが、先にあげた型については、正しく検知が出来ていなかったもよう。知らなかった。


Through associations should set both parent ids on join models

ActiveRecordの修正です。

saveを行う際、親クラスのidもセットされるよう対応しています。

コミットログの例から抜粋。

member = Member.new(club: Club.new)
member.save!

# Before:
member.current_membership.club_id # => nil

# After:
member.current_membership.club_id # => club's id

Fix request's path_info when a rack app mounted at '/'.

actionpack/lib/action_dispatch/journey/router.rbの修正です。

rack appを'/'にマウントした時に、`env['PATH_INFO']からスラッシュが消えてしまっていたのを修正しています。


Open extension point for defining options in build_through_record

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

以下のようなケースでエラーになってしまったのを修正しています。

class Group < ActiveRecord::Base
  ...
  has_many :members, :through => :memberships, :source => :user
end

group.members << user

リグレッション対応。


Remove serialized? from the type interface

ActiveRecordのtype classの修正です。

serialized?メソッドを削除しています。


Parsing DATABASE_URI, use URI#hostname: it's smarter about IPv6

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

DATABASE_URIURI#hostnameを使用するよう修正しています。IPv6対応。


SecurePassword - Validate password must be less than or equal to 72

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

パスワードの最大長を設定しています。値は72です。BCryptで生成される値の最大長が72だからとの事です。


Added changelog for #15708 [ci skip]

先ほどのパスワード最大長の修正について、CHANGELOGに追記しています。


Cleaned up the has_secure_password test cases

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

テスト処理をまとめたり、不要なテストケースを削除したり対応しています。


Make sure restoration always happen.

actionview/test/template/digestor_test.rbの修正です。

ActionView::Resolver.cachingの値を元に戻す処理を、ensureブロックで実行するよう修正しています。必ず実行されるようにですね。


Avoid hard-coded value in test setup and teardown.

actionview/test/template/javascript_helper_test.rbの修正です。

値がハードコードされていたのを、メソッドから値を取得するよう修正しています。


Use @existing_user while updating existing user, fixing - #ee4e86

activemodel/test/cases/secure_password_test.rbの修正です

@userを使用している箇所を、@existing_userを使用するよう修正しています。

@userインスタンス生成しているだけで、実際DBにデータがあるインスタンスでは無いようです。


pg guide, use the term database views to be specific. [ci skip]

rails guideのActive Record and PostgreSQLの修正です

viewsdatabase viewsに修正しています。


Deprecate serialized_attributes without replacement

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

serialized_attributesがdeprecateになりました。代わりにtype objectを使用するゆうに、との事です。


[ci skip] Update #has_secure_password docs

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

has_secure_passwordメソッドのdocを修正しています。パスワード最大長が72文字である旨説明を追加しています。


docs, remove getting started guide sample application. [ci skip]

rails guideのgetting started guideにあったサンプルアプリを削除しています。

メンテがされてない、かつ、そもそもguideの中で説明しているので、不要なのでは、との事です。