method

select_hour

select_hour()
public

No documentation available.

# File actionview/lib/action_view/helpers/date_helper.rb, line 788
      def select_hour
        if @options[:use_hidden] || @options[:discard_hour]
          build_hidden(:hour, hour)
        else
          options         = {}
          options[:ampm]  = @options[:ampm] || false
          options[:start] = @options[:start_hour] || 0
          options[:end]   = @options[:end_hour] || 23
          build_options_and_select(:hour, hour, options)
        end
      end

2Notes

Correction

mestrecapablanca · Nov 7, 20132 thanks

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

edivandecastro · Apr 2, 20121 thank

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: