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
I happened to have a plugin laying around to accomplish this. http://www.railtie.net/plugins/time_select.zip Enjoy. Bob Pat Maddox wrote:> 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
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/> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org [mailto:rails- > bounces@lists.rubyonrails.org] On Behalf Of Bob Silva > Sent: Monday, February 06, 2006 11:15 PM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] Is there a good time_select tag helper? > > I happened to have a plugin laying around to accomplish this. > > http://www.railtie.net/plugins/time_select.zip > > Enjoy. > > Bob > > Pat Maddox wrote: > > 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 > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Hey Bob, This worked great, thanks a lot. Pat On 2/7/06, Bob Silva <me@bobsilva.com> wrote:> I happened to have a plugin laying around to accomplish this. > > http://www.railtie.net/plugins/time_select.zip > > Enjoy. > > Bob > > Pat Maddox wrote: > > 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 > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
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-- Posted via http://www.ruby-forum.com/.
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 zipJust put the time_select folder in vendor/plugins Pat
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-- Posted via http://www.ruby-forum.com/.
Bob Silva wrote:> I happened to have a plugin laying around to accomplish this. > > http://www.railtie.net/plugins/time_select.zip > > Enjoy. > > BobThis 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---