You have a model Store with an attribute time_zone(New York, London, Tokyo, etc.).
All stores are open from 8am to 9pm in their local time zone.
You have an instance method to check if the store is currently open:
def currently_open?
current_store_time = Time.now.in_time_zone(time_zone)
(8...21).cover? current_store_time.hour
end
How do you create a rails scope for all currently open stores using the Store#currently_open? instance method (or without that method, but I want to use the rails scope syntax).
scope :currently_open, -> { "use Store#currently_open? here" }
time_zone, what RDMBS are you using (if any)?(8..21).cover? current_store_timewill always returnfalse. You have to compare againstcurrent_store_time.hourand you probably want8...21(triple dot), i.e. up to but not including 21. (unless the stores are open until 9:59pm)