なるようになるブログ

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

rails commit log流し読み(2014/04/22)

2014/04/22分のコミットです。

favicon_link_tagで生成されるHTMLのdefaultのMIMEタイプが変更されています。


Rearrange deck chairs on the titanic. Organize connection handling test cases.

ActiveRecord::ConnectionAdaptersのテストの修正です。テストコードの書き先を修正しています。


select! renamed to avoid name collision Array#select!

ActiveRecord::QueryMethods::WhereChainselect!メソッドを_select!メソッドに名前を変更しています。

ActiveRecord_RelationがArrayのような振る舞いをしている為、Array#select!の挙動を期待してselect!を実行したのに結果がおかしい、issueがあった為、メソッド名を変更して、明示的にNoMethodErrorが出るようにしています。

Before:
  todos = Todo.all
  todos.select!{|t| false} # ActiveRecord::ImmutableRelation: ActiveRecord::ImmutableRelation

After:
  todos = Todo.all
  todos.select!{|t| false} # NoMethodError: undefined method `select!' for #<Todo::ActiveRecord_Relation:0x007f9758745508>

rails 4.1だと、そもそも動かない感じでした。


Add test for using ActionView::Helpers::FormHelper.label with block and html

ActionView::Helpers::FormHelper.labelメソッドのテストケースを追加しています。


Merge pull request #10764 from mokevnin/replace_class_eval_by_define_method

abstract_controller/callbacks動的にメソッドを生成するのに、class_evalを使っていたのをdefine_methodを使うように修正しています。

class_eval/define_methodを使った場合の性能の違い等について、tenderloveのブログに詳しい説明が載っています。

define_methodの方が速度早いんですね。処理的にも、メソッドを定義している、事が明確になって良い気がします。


Merge pull request #13335 from glorieux/favicon_link_tag_mimetype

favicon_link_tagのdefaultのMIMEタイプが変更されました。

Before:
  #=> favicon_link_tag 'myicon.ico'
  <link href="/assets/myicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />

After:
  #=> favicon_link_tag 'myicon.ico'
  <link href="/assets/myicon.ico" rel="shortcut icon" type="image/x-icon" />

favicon、基本MIMEimage/x-iconで指定するのですが、IANAに登録されいているのは、image/vnd.microsoft.iconなんですよね。ややこしい。


Fix run-on sentences and improve grammar [skip ci]

rails guideの修正。Getting Startedのグラマーの修正です。