I''ve tried the simple_date_select plugin and it works as advertised (Thank you so much!), that is it converts the unwieldy default date selection boxes into a single text field with the default date format like yyyy-mm-dd. And, I played with the extension to that plugin proposed by Jeremy Evans that uses strftime(''%m/%d/%Y'') to get it reformatted like mm/dd/yyyy (Thank you, too, Jeremy). My problem is that I can''t quite get strftime to format the dates exactly as I''d like to see them, which is like 6/3/2006 (no zero or space before the 6 and no zero or space before the 3). Being new to Ruby, I''m weak on Ruby syntax. Jeremy''s suggested code is: def to_date_select_tag(options = {}) to_input_field_tag(''text'', {''size''=>''10'', ''value''=>value.strftime(''%m/%d/%Y'')}.merge(options)) end I tried to substitute a block {} for the expression value.strftime(''%m/%d/%Y'') and failed miserably. Can anyone help me out with some expression to convert a date string like 06/03/2006 to one like 6/3/2006 that I can plug into the above method? Thanks, this forum has been SOOOO helpful! Shauna -- 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 -~----------~----~----~----~------~----~------~--~---
How about date = Date.today "#{date.month}/#{date.day}/#{date.year}" Long --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Wow, Long, that was perfect! Shauna -- 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 -~----------~----~----~----~------~----~------~--~---
There''s one more item to consider here, and that''s how to treat nil dates. I did figure out the answer to this one, so I''m posting the solution here for others who might want to alter the plugin similarly to get a m/d/yyyy format: Replace the plugin line to_input_field_tag(''text'', {''size''=>''10''}.merge(options)) with if value.nil? then to_input_field_tag(''text'', {''size''=>''10''}.merge(options)) else to_input_field_tag(''text'', {''size''=>''10'', ''value''=>"#{value.month}/#{value.day}/#{value.year}"}.merge(options)) end I hope this helps others. I haven''t tried altering the datetime portion of the plugin because I don''t need datetimes, but I imagine similar code would be needed there as well. Shauna -- 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 -~----------~----~----~----~------~----~------~--~---