select_hour

- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1 (0)
- 2.3.2 (0)
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- What's this?

Correction
Where you see:
HelperData.new(datetime, options, html_options).select_hour
The correct would be:
HelperDate.new(datetime, options, html_options).select_hour
Class name and class instance must be same name.
Code works fine in Rails 3.2.13.

Options select_hour
In my view I wanted to do this <%= select_hour(@hour, :start => 8, :end => 12) %> but did not work. I looked at the documentation and have not seen anything like it. http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-select_hour
So I studied how it worked this helper. http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-select_hour develop and achieve this:
the helper application:
module DataAnnouncementsHelper
class HelperDate < ActionView::Helpers::DateTimeSelector def select_hour if @options[:use_hidden] || @options[:discard_hour] build_hidden(:hour, hour) else build_options_and_select(:hour, hour, :end => @options[:end], :start => @options[:start], :ampm => @options[:ampm]) end end end def select_hour(datetime, options = {}, html_options = {}) HelperData.new(datetime, options, html_options).select_hour end
end
The view:
<%= select_hour(@hour, :start => 8, :end => 12) %>
Where @hour = 10 the result is:
<select id=“date_hour” name=“date[hour]”>
<option value="08">08</option> <option value="09">09</option> <option value="10" selected="selected">10</option> <option value="11">11</option> <option value="12">12</option>
</select>