Is there a good time_select tag helper?


#1

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


#2

I happened to have a plugin laying around to accomplish this.

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

Enjoy.

Bob


#3

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/


#4

Hey Bob,

This worked great, thanks a lot.

Pat


#5

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


#6

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


#7

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


#8

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)


#9

Oops. I figured I had to install it like other plugings.

:blush:

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


#10

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.