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.
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-02-07 06: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
Af93ba6b6b59f22a8f37e8de5702ef98?d=identicon&s=25 Bob Silva (Guest)
on 2006-02-07 08: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
Af93ba6b6b59f22a8f37e8de5702ef98?d=identicon&s=25 Bob Silva (Guest)
on 2006-02-07 08: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 Silva
http://www.railtie.net/
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-02-07 08:32
(Received via mailing list)
Hey Bob,

This worked great, thanks a lot.

Pat
85e05b7260af81cbacfea7e7ed4f40fb?d=identicon&s=25 Guest (Guest)
on 2006-05-25 06: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 Silva wrote:
> I happened to have a plugin laying around to accomplish this.
>
> http://www.railtie.net/plugins/time_select.zip
>
> Enjoy.
>
> Bob
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-05-25 06:58
(Received via mailing list)
On 5/24/06, Guest <blamemike@gmail.com> 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
85e05b7260af81cbacfea7e7ed4f40fb?d=identicon&s=25 Guest (Guest)
on 2006-05-25 14:32
Oops. I figured I had to install it like other plugings.

:-$

Thanks Pat!


Pat Maddox wrote:
> On 5/24/06, Guest <blamemike@gmail.com> 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
59a546d1e843ee014bf832fae8ab729b?d=identicon&s=25 Brad Adams (cajuncanuck)
on 2006-11-06 18:11
Bob Silva 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
59a546d1e843ee014bf832fae8ab729b?d=identicon&s=25 Brad Adams (cajuncanuck)
on 2006-11-06 20: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)
59a546d1e843ee014bf832fae8ab729b?d=identicon&s=25 Brad Adams (cajuncanuck)
on 2006-11-09 21: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.