Last active
April 3, 2019 20:39
-
-
Save invalidusrname/15995 to your computer and use it in GitHub Desktop.
Makes a select tag (1-30min with 30 sec intervals)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert_to_duration(fixnum) | |
min = (fixnum / 60).to_s.rjust(2, '0') | |
sec = (fixnum % 60).to_s.rjust(2, '0') | |
"00:#{min}:#{sec}" | |
end | |
(1.minute..30.minutes).step(30).collect { |s| convert_to_duration(s) } | |
# 00:01:00 | |
# 00:01:30 | |
# 00:02:00 | |
# 00:02:30 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% durations = ['Choose One'] | |
durations << (1.minute..30.minutes).step(30).collect { |s| convert_to_duration(s) } | |
durations.flatten! | |
%> | |
<%= select_tag("duration", options_for_select(durations)) %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment