Forum: Ruby How to get just hour and minute?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
(Guest)
on 2009-03-16 21:25
(Received via mailing list)
I have a Ruby project with a User object that consists of various
fields (attributes). Two of these are preferredStart and preferredEnd
and were configured with the "... script/generate scaffold ..."
command to have type "time".  When I visit the resulting "New User"
page, the input for those two fields has date and time. In other
words, the user could select a month, date and year in addition to
hour, minute and second for preferredStart and preferredEnd. The
relevent code from the view/new_user.html.erb is:

  <p>
    <%= f.label :preferredStart %><br />
    <%= f.datetime_select :preferredStart %>
  </p>
  <p>
    <%= f.label :preferredEnd %><br />
    <%= f.datetime_select :preferredEnd %>
  </p>
  <p>

Is there a way to limit the input selection to simply hour and
minute?  I tried, for instance:

<%= f.datetime_select :preferredStart, prompt => {:hour =>
true, :minute => true} %>

That did not have the intended effect, though.
Craig D. (Guest)
on 2009-03-16 21:32
(Received via mailing list)
Have a look at time_select.

http://www.railsbrain.com/api/rails-2.2.2/doc/inde...

Regards,
Craig
Craig D. (Guest)
on 2009-03-16 21:45
(Received via mailing list)
By the way, you should ask Rails questions here:

http://groups.google.com/group/rubyonrails-talk

Regards,
Craig

On Mon, Mar 16, 2009 at 3:29 PM, Craig D.
(Guest)
on 2009-03-16 21:46
(Received via mailing list)
On Mar 16, 3:29 pm, Craig D. <removed_email_address@domain.invalid> wrote:
> [Note:  parts of this message were removed to make it a legal post.]

Had I included content that was not 'legal'? Apologies to all if I
had.

> Have a look at time_select.
>
> http://www.railsbrain.com/api/rails-2.2.2/doc/inde......

That did it, thank you for the quick reply and the nudge in the right
direction. As you probably have guessed, I'm way down on the left side
of the learning curve. Thanks!

AG
This topic is locked and can not be replied to.