aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-01-16 23:55:48 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-01-17 00:05:31 -0300
commitb69e449c512d68b54af3d15cdf2d92181c2817d7 (patch)
treedc9aa4af4a8cf9e9d7b122df380132427eaa51b5 /actionpack
parente70f68fd1ebcb35a9f82b0b3c5a6ea14a4e253cc (diff)
downloadrails-b69e449c512d68b54af3d15cdf2d92181c2817d7.tar.gz
rails-b69e449c512d68b54af3d15cdf2d92181c2817d7.tar.bz2
rails-b69e449c512d68b54af3d15cdf2d92181c2817d7.zip
Extract TimeSelect
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/active_model_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb6
-rw-r--r--actionpack/lib/action_view/helpers/tags.rb1
-rw-r--r--actionpack/lib/action_view/helpers/tags/date_select.rb6
-rw-r--r--actionpack/lib/action_view/helpers/tags/time_select.rb8
5 files changed, 16 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/helpers/active_model_helper.rb b/actionpack/lib/action_view/helpers/active_model_helper.rb
index 06137f6be6..cb801e50c4 100644
--- a/actionpack/lib/action_view/helpers/active_model_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_model_helper.rb
@@ -16,7 +16,7 @@ module ActionView
end
end
- %w(content_tag to_datetime_select_tag to_time_select_tag).each do |meth|
+ %w(content_tag to_datetime_select_tag).each do |meth|
module_eval "def #{meth}(*) error_wrapping(super) end", __FILE__, __LINE__
end
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index d1d802de53..fb80996dfa 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -251,7 +251,7 @@ module ActionView
# Note: If the day is not included as an option but the month is, the day will be set to the 1st to ensure that
# all month choices are valid.
def time_select(object_name, method, options = {}, html_options = {})
- InstanceTag.new(object_name, method, self, options.delete(:object)).to_time_select_tag(options, html_options)
+ ActionView::Helpers::Tags::TimeSelect.new(object_name, method, self, options, html_options).render
end
# Returns a set of select tags (one for year, month, day, hour, and minute) pre-selected for accessing a
@@ -975,10 +975,6 @@ module ActionView
end
module DateHelperInstanceTag
- def to_time_select_tag(options = {}, html_options = {})
- datetime_selector(options, html_options).select_time.html_safe
- end
-
def to_datetime_select_tag(options = {}, html_options = {})
datetime_selector(options, html_options).select_datetime.html_safe
end
diff --git a/actionpack/lib/action_view/helpers/tags.rb b/actionpack/lib/action_view/helpers/tags.rb
index b81c515c49..cc8af5f417 100644
--- a/actionpack/lib/action_view/helpers/tags.rb
+++ b/actionpack/lib/action_view/helpers/tags.rb
@@ -21,6 +21,7 @@ module ActionView
autoload :GroupedCollectionSelect, 'action_view/helpers/tags/grouped_collection_select'
autoload :TimeZoneSelect, 'action_view/helpers/tags/time_zone_select'
autoload :DateSelect, 'action_view/helpers/tags/date_select'
+ autoload :TimeSelect, 'action_view/helpers/tags/time_select'
end
end
end
diff --git a/actionpack/lib/action_view/helpers/tags/date_select.rb b/actionpack/lib/action_view/helpers/tags/date_select.rb
index 2f2681bf65..5912598ca1 100644
--- a/actionpack/lib/action_view/helpers/tags/date_select.rb
+++ b/actionpack/lib/action_view/helpers/tags/date_select.rb
@@ -9,11 +9,15 @@ module ActionView
end
def render
- error_wrapping(datetime_selector(@options, @html_options).select_date.html_safe)
+ error_wrapping(datetime_selector(@options, @html_options).send("select_#{select_type}").html_safe)
end
private
+ def select_type
+ self.class.name.split("::").last.sub("Select", "").downcase
+ end
+
def datetime_selector(options, html_options)
datetime = value(object) || default_datetime(options)
@auto_index ||= nil
diff --git a/actionpack/lib/action_view/helpers/tags/time_select.rb b/actionpack/lib/action_view/helpers/tags/time_select.rb
new file mode 100644
index 0000000000..9e97deb706
--- /dev/null
+++ b/actionpack/lib/action_view/helpers/tags/time_select.rb
@@ -0,0 +1,8 @@
+module ActionView
+ module Helpers
+ module Tags
+ class TimeSelect < DateSelect #:nodoc:
+ end
+ end
+ end
+end