From f2ae4af9e122fd1daa95fd7249bdcf1068ebeecb Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Thu, 29 Oct 2015 11:15:19 -0600 Subject: Fix style issues with #16252 --- actionview/CHANGELOG.md | 8 ++++---- actionview/lib/action_view/helpers/date_helper.rb | 13 +++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'actionview') diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index b37a275fe0..65314184c8 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,7 @@ +* Allow `date_select` helper selected option to accept hash like the default options. + + *Lecky Lao* + * Collection input propagates input's `id` to the label's `for` attribute when using html options as the last element of collection. @@ -208,8 +212,4 @@ *Daniel Gomez de Souza* -* Allow date_select helper selected option to accept hash like the default options. - - *Lecky Lao* - Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/actionview/CHANGELOG.md) for previous changes. diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb index c69e4cc77e..233e613e97 100644 --- a/actionview/lib/action_view/helpers/date_helper.rb +++ b/actionview/lib/action_view/helpers/date_helper.rb @@ -845,14 +845,11 @@ module ActionView private %w( sec min hour day month year ).each do |method| define_method(method) do - if @datetime - if @datetime.kind_of?(Hash) - @datetime[method.to_sym] - elsif @datetime.kind_of?(Numeric) - @datetime - else - @datetime.send(method) - end + case @datetime + when Hash then @datetime[method.to_sym] + when Numeric then @datetime + when nil then nil + else @datetime.send(method) end end end -- cgit v1.2.3