なるようになるブログ

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

rails commit log流し読み(2014/08/25)

2014/08/25分のコミットです。

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

activerecord/CHANGELOG.md

actionview/CHANGELOG.md


[ci skip] Added documentation for has_many extension parameter

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

has_many scopeにパラメータを渡すサンプルを追加しています。

has_many :employees do
  def find_or_create_by_name(name)
    first_name, last_name = name.split(" ", 2)
    find_or_create_by(first_name: first_name, last_name: last_name)
  end
end

Grammer and spelling pass on web console release note. [CI SKIP]

rails guideのRuby on Rails 4.2 Release Notesの修正です

グラマー及びスペルミスの修正です。


Follow-up to #16560

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

instance_of?メソッドでクラスで保持しているvalueとのinstance_of?チェックも追加しています。

-      Duration == klass
+      Duration == klass || value.instance_of?(klass)

PRのコメント見た感じだと、下位互換を壊してしまうっていたので、処理を修正した感じのようです。


Skip #eql? tests on Rubinius for AS::Duration

activesupport/test/core_ext/duration_test.rbの修正です。

eql?メソッドのテストについて、Rubiniusの場合のみスキップするよう対応しています。

Rubiniusのeql?メソッドinstance_of?メソッドに依存しており、先に対応したinstance_of?メソッドの対応でテストがコケてしまうので、一旦スキップするよう対応したようです。


Fix a few typos [ci skip]

activejob/lib/active_job/arguments.rbactiverecord/lib/active_record/associations.rbの修正です。

typoの修正。


Some tweaks to the development set-up guide

rails guideのDevelopment Dependencies Installの修正です。

  • libxml2 とlibxsltの説明について削除。Nokogiriに含まれてるとの事。
  • Arch LinuxFreeBSDの場合のmemcachedのインストール手順追加
  • 新しいpkg installシンタックスに対応
  • 重複しているHomebrewへのリンクを削除

等々。


Whoops, duplicated word [ci skip]

rails guideのDevelopment Dependencies Installの修正です。

typoの修正です。


treetop is no longer a mail (rails) dependency

rails guideのThe Rails Initialization Processの修正です。

Railsが使用しているgemの説明から、polyglottreetopを削除しています。


Address comments on Gzip implementation

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

Gzip対応のPRで指摘されたコメントに対する対応です。リファクタリング


[ActiveJob] Add activesupport as dependency [ci skip]

activejob/activejob.gemspecの修正です。

dependencyactivesupportを追加しています。


Merge pull request #16639 from agrobbin/input-placeholder-i18n

デグレに対応したinput/textarea placeholder textへのi18nサポート対応を、再度コミットしています。


pg, default_sequence_name needs to return a string.

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

default_sequence_nameメソッドがStringを返すよう修正しています。

元々Stringを返す仕様で4.2.beta1で仕様が変わったのですが、sequence_nameはpublic APIなので、型は変わらない方が良いだろうという事で、Stringに戻しています。

実際、seed-fuがこの影響で動かなくなったりしていたようです。


Merge pull request #16488 from agrobbin/form-label-builder

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

labelメソッド用のbuilderとして、LabelBuilderクラスを新規に作成しています。

このLabelBuilderクラスはi18nに対応した値を返す為の、translationメソッドが提供されています。

テストから抜粋。

label(:post, :body) { |b| "<b>#{b.translation}</b>".html_safe }
# => '<label for="post_body"><b>Write entire text here</b></label>'

i18n対応が必要な時には便利そうですね。