なるようになるブログ

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

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

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

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

actionpack/CHANGELOG.md

actionview/CHANGELOG.md


Fix handling of positional url helper arguments when format is false https://github.com/rails/rails/commit/1a50be823186082e8b5a29d8e9ea3a289318d9c1

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

routingにformat: falseを指定した場合に、url helperが引数の扱いに誤りがあるバグがあったのを修正しています。

-              if args.size < path_params.size - 1 # take format into account
+              # take format into account
+              if path_params.include?(:format)
+                path_params_size = path_params.size - 1
+              else
+                path_params_size = path_params.size
+              end
+
+              if args.size < path_params_size

"format"がある前提でpath_param.size -1を行っているのですが、format: falseの場合"format"が無いので、判定がおかしくなってしまっていたようです。


ParameterFilter shouldn't try to dup symbol keys

actionpack/lib/action_dispatch/http/parameter_filter.rbの修正です。

ParameterFilterクラスでkeyの複製を行う際、duplicable?チェックを行うよう修正しています。

{:controller=>"samples", :action=>"index"}のように、keyがsymbolの場合にdup出来なくてエラーになってしまうバグの対応です。


allow URL helpers to work with optional scopes

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

optional scopesを使用している際に、URL helpersが正しい値を返すよう修正しています。

draw do
  scope "(/:foo)" do
    resources :users
  end
end

url_helpers.user_path(1)              # => '/users/1'
url_helpers.user_path(1, foo: nil)    # => '/users/1'
url_helpers.user_path(1, foo: 'a')  # => '/a/users/1'

Re-enable capture'ing non-String values

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

CaptureHelper#captureメソッドがString以外の値もcaptureするよう修正しています。

# before
ActionView::Base.new.capture { 1 }  #=> nil

# after
ActionView::Base.new.capture { '1' }  #=> nil

内部でcaptureメソッドを呼び出しているので、content_tagメソッドも同じように挙動の変更があります。

# before
content_tag(:p) { 1.0 } # => <p></p>

# after
content_tag(:p) { 1.0 } # => <p>1.0</p>

Merge pull request #18024 from carpodaster/fix/actionview/capture-non-strings