Last active
December 13, 2015 17:38
-
-
Save jmercedes/4949128 to your computer and use it in GitHub Desktop.
This file contains 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
<%= f.select :atime, @time_options %> |
This file contains 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
undefined method `empty?' for nil:NilClass |
This file contains 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 self.time_options | |
start_of_day = Time.zone.now.beginning_of_day | |
start_time = start_of_day + 9.hours | |
end_time = start_of_day + 17.hours | |
lunch_start = start_of_day + 13.hours | |
lunch_end = start_of_day + 14.hours + 30.minutes | |
times = [] | |
until start_time > end_time | |
start_time = (start_time + 30.minutes) | |
unless start_time >= lunch_start && start_time < lunch_end | |
times << start_time | |
end | |
end | |
times.map{|t| [t.strftime("%I:%M%p").downcase, t.to_s(:db)] } | |
end |
This file contains 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 new | |
@time_options = Appointment.time_options | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment