4

I want to remove the ":" from the output of the rails time_select helper. The helper seems to output this automatically when the minutes select box is built.

Any ideas?

Thanks!

Tony
  • 18,776
  • 31
  • 129
  • 193

1 Answers1

9

The output from those helpers are usually just strings, so you should be able to say:

<%= time_select("post", "sunrise").gsub(/:/, ' ') %>

[Edit] Turns out a cleaner solution is to just say:

<%= time_select("post", "sunrise", :time_separator => "" %>
Terry
  • 1,088
  • 6
  • 10
  • this solution is OK, but I was hoping to be able to pass some parameter into the build_select method. the reason is i have a plugin that overrides the way rails handles the time_select helper. the code is here: http://github.com/tamoyal/simple_time_select/blob/91de19740ce23db240f78085ada29c30e42bf1ef/lib/simple_time_select.rb , i cannot find any good documentation on the build_select method – Tony Apr 22 '09 at 03:00
  • sorry, but do you see lines 32 and 33 of that code snippet? why not just remove the colons from there, between #{ampm_hour} and #{minute_padded}? would that do what you want? – Terry Apr 22 '09 at 13:13
  • those are the colons in the time values, for example "12:45". the problem i have is the select automatically puts a colon outside of the select box....because usually you have a separate select field for hours and minutes. for example, : ..so i need to remove the colon that is automatically printed outside of the select box – Tony Apr 22 '09 at 20:28
  • ahh, gotcha. sorry for the misunderstanding. i don't even think gsub will do what you want, then, since that's screw up the 12:45. try passing a :time_separator to options, like: <%= time_select("post", "sunrise", :time_separator => "") %> that work? – Terry Apr 23 '09 at 01:12