Forum: Ruby on Rails Is there a good time_select tag helper?

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.
Pat M. (Guest)
on 2006-02-07 07:34
(Received via mailing list)
I'm trying to record a list of start and end times, and they're simply
an hour and a minute.  Looking at the API, there's a select_time
helper, but that just creates the tag.  There's a datetime_select
helper which takes an object and method name, so it does all the
magic...but I only want to worry about the hour and the minute.  I've
tried writing my own so far and have not been able to figure anything
out.  Does anyone have code for a time_select helper that does the
magic of filling in the fields and everything?

Pat
Bob S. (Guest)
on 2006-02-07 09:17
(Received via mailing list)
I happened to have a plugin laying around to accomplish this.

http://www.railtie.net/plugins/time_select.zip

Enjoy.

Bob
Bob S. (Guest)
on 2006-02-07 09:20
(Received via mailing list)
And usage info:

<%= time_select 'model', 'field' %>

It works by modifying the date_select function to output the date fields
as
hidden fields. This allows Rails to properly convert it to a datetime
assuming your database will handle the conversion from a datetime to a
time
value. (MySQL does)


Bob S.
http://www.railtie.net/
Pat M. (Guest)
on 2006-02-07 09:32
(Received via mailing list)
Hey Bob,

This worked great, thanks a lot.

Pat
Guest (Guest)
on 2006-05-25 08:40
I just downloaded this, and tried to install it, but, I get a plugin not
found error.

I extracted the files from the zip and ran:

ruby script/plugin install 'path to time_select', and I always get a not
found.

Any ideas.

Thanks in Advance.

M.


Bob S. wrote:
> I happened to have a plugin laying around to accomplish this.
>
> http://www.railtie.net/plugins/time_select.zip
>
> Enjoy.
>
> Bob
Pat M. (Guest)
on 2006-05-25 08:58
(Received via mailing list)
On 5/24/06, Guest <removed_email_address@domain.invalid> wrote:
> I just downloaded this, and tried to install it, but, I get a plugin not
> found error.
>
> I extracted the files from the zip

Just put the time_select folder in vendor/plugins

Pat
Guest (Guest)
on 2006-05-25 16:32
Oops. I figured I had to install it like other plugings.

:-$

Thanks Pat!


Pat M. wrote:
> On 5/24/06, Guest <removed_email_address@domain.invalid> wrote:
>> I just downloaded this, and tried to install it, but, I get a plugin not
>> found error.
>>
>> I extracted the files from the zip
>
> Just put the time_select folder in vendor/plugins
>
> Pat
Brad A. (Guest)
on 2006-11-06 19:11
Bob S. wrote:
> I happened to have a plugin laying around to accomplish this.
>
> http://www.railtie.net/plugins/time_select.zip
>
> Enjoy.
>
> Bob

This worked great for me (1.1.6) until I switched over to edge.  Anyone
know how to get it running on edge?  Or another plugin with the same
functionality?

Brad
Brad A. (Guest)
on 2006-11-06 21:55
> This worked great for me (1.1.6) until I switched over to edge.  Anyone
> know how to get it running on edge?  Or another plugin with the same
> functionality?

I should add that I'm getting this error:
/vendor/plugins/time_select/lib/time_select.rb:16:in `value': wrong
number of arguments (0 for 1)
Brad A. (Guest)
on 2006-11-09 22:47
Brad Adams wrote:
>
>> This worked great for me (1.1.6) until I switched over to edge.  Anyone
>> know how to get it running on edge?  Or another plugin with the same
>> functionality?
>
> I should add that I'm getting this error:
> /vendor/plugins/time_select/lib/time_select.rb:16:in `value': wrong
> number of arguments (0 for 1)

This did the trick.

I changed this line in the plugin
datetime = options[:include_blank] ? (value || nil) : (value ||
Time.now)
to
datetime = options[:include_blank] ? (value(object) || nil) :
(value(object) || Time.now)

Hope that helps anyone else going through the upgrade to edge.
This topic is locked and can not be replied to.