なるようになるブログ

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

rails commit log流し読み(2014/07/30)

2014/07/30分のコミットです。

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

activesupport/CHANGELOG.md


Get request should not write to database note added. [skip ci]

rails guideのRails Routing from the Outside Inの修正です。

GETメソッドCSRF tokenのチェックをしないので、GETリクエストでDBに書き込むような処理をするな、という注意事項を追加しています。大事。


:nail_care: from #16329 [ci skip]

rails guideのRails Routing from the Outside Inの修正です。

先ほどのコミットについて、言い回しの修正、スペースの削除等を行っています。


eval_block should be private

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

eval_blockをprivateにしています。


only ask for the routes module once

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

routes.named_routes.moduleの結果を変数に代入して、呼び出しを一回で済ますよう修正しています。


pass the module to define_named_route_methods

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

define_named_route_methodsメソッドの引数にmoduleを追加しています。これにより、@module削除出来る、との事なのですが、まだ使っているよな…。


helpers should be a Set so it doesn't grow unbounded

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

@helpersのクラスをArrayからSetに変更しています。

so it doesn't grow unboundedとコミットログにあるので、データが増えた際の事を考慮して、検索速度が早いSetに切り替えた、という事でしょうか。


ask the named routes collection if the route is defined

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

ルーティングが設定されているか確認する為のroute_defined?メソッドを追加しています。


oops! :bomb:

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

先程追加されたroute_defined?メソッドに誤りがあったのを修正しています。

-          @module.method_defined? name
+          @helpers.include? name.to_sym

こんな感じで。


Add implicit receiver support to Object#with_options

activesupport/lib/active_support/core_ext/object/with_options.rbの修正です。

Object#with_optionsでreceiverが指定されなかった際の挙動が変更になっています。

# before
class Account < ActiveRecord::Base
  with_options dependent: :destroy do |assoc|
    assoc.has_many :customers
    assoc.has_many :products
    assoc.has_many :invoices
    assoc.has_many :expenses
  end
end
# after
class Account < ActiveRecord::Base
  with_options dependent: :destroy do
    has_many :customers
    has_many :products
    has_many :invoices
    has_many :expenses
  end
end

大分スッキリ書けるように。

Method#arityで引数の数のチェックが出来る事を初めて知りました。


Merge pull request #15959 from aditya-kapoor/remove-unneeded-cases

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

使用してないテスト用のmodelを削除しています。


Revert "Merge pull request #15305 from tgxworld/remove_unnecessary_require"

こちらのコミットをrevertしています。

不要なrequire 'minitest'を削除したコミットだったのですが、実は必要で、これがないとrails console上でappメソッドを呼び出すとエラーになってました。

require 'minitest'を追加するPRを出していたのですが、Revertで対応が行われました。