Flowdock
select_hour() public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Show source
Register or log in to add new notes.
November 7, 2013
2 thanks

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.

April 2, 2012
1 thank

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>