Hello, I would like to turn a regular 24 hour time select input into a 12 hour time select with an additional AM/PM select input. For example: Before: [00..23] : [00..59] After: [1..12] : [00..59] [AM,PM] I''m really surprised that this sort of thing doesn''t come standard in Rails. Has this been done before? Is there a plugin or gem that I can install? If not, how can I create this from scratch? Thanks, Andrew -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/fZijJFXm3XsJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Why not just write your own html? A lot of this rails stuff is ridiculously complicated for the simple html it produces. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I could easily write the HTML to create a few select elements, however, it''s the Ruby part that I am not as familiar with. Could you provide an example of what the controller code (or model, helper, etc) would look like to convert the 3 fields into a valid time value ready to store in a database? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/eYuCw14obR4J. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dheeraj Kumar
2011-Aug-14 07:14 UTC
Re: Re: How to create a custom time select form element?
I highly recommend using jQueryUI Datepicker for more usable date selection. However, if you want to have it your way, create fields in your model for all the select boxes, and use the before_save callback to construct the final date field for storing in the database. Refer http://guides.rubyonrails.org/form_helpers.html#barebones-helpers On Sun, Aug 14, 2011 at 12:12 PM, Andrew <misbehavens-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I could easily write the HTML to create a few select elements, however, > it''s the Ruby part that I am not as familiar with. Could you provide an > example of what the controller code (or model, helper, etc) would look like > to convert the 3 fields into a valid time value ready to store in a > database? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/eYuCw14obR4J. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 14 August 2011 07:42, Andrew <misbehavens-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I could easily write the HTML to create a few select elements, however, it''s the Ruby part that I am not as familiar with. Could you provide an example of what the controller code (or model, helper, etc) would look like to convert the 3 fields into a valid time value ready to store in a database?Just take the params values and convert them into a Time object. Time.utc or Time.local may be useful. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> however, it''s the Ruby part that I am not as familiar with. >Then it''s time to put rails away and buy a beginning ruby book. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dheeraj Kumar
2011-Aug-14 08:26 UTC
Re: Re: How to create a custom time select form element?
The Ruby Programming Language by Matz is my personal favorite. You might want to try that. On Sun, Aug 14, 2011 at 1:05 PM, 7stud -- <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > however, it''s the Ruby part that I am not as familiar with. > > > > Then it''s time to put rails away and buy a beginning ruby book. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.