From 462698b2c704eff962060ed5851af80f4215958b Mon Sep 17 00:00:00 2001 From: Lecky Lao Date: Tue, 22 Jul 2014 16:03:55 +1000 Subject: making selected value to accept Hash like the default option. E.g. selected: {day: params[:day].to_i, month: params[:month].to_id} Adds in test test_date_select_with_selected_in_hash and change log fixes typo in CHANGELOG --- actionview/lib/action_view/helpers/date_helper.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb index 312e41ee48..c69e4cc77e 100644 --- a/actionview/lib/action_view/helpers/date_helper.rb +++ b/actionview/lib/action_view/helpers/date_helper.rb @@ -845,7 +845,15 @@ module ActionView private %w( sec min hour day month year ).each do |method| define_method(method) do - @datetime.kind_of?(Numeric) ? @datetime : @datetime.send(method) if @datetime + if @datetime + if @datetime.kind_of?(Hash) + @datetime[method.to_sym] + elsif @datetime.kind_of?(Numeric) + @datetime + else + @datetime.send(method) + end + end end end -- cgit v1.2.3 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/lib/action_view/helpers/date_helper.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'actionview/lib') 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