I'm new to Rails and I'm trying to develop a simple Alarm Clock in Rails 4. Basically you should be able to set the time of the alarm. On the index page (main page) you will see "number 5" image that will gradually change to "4", "3", "2" and "1" approaching the time when it is supposed to go off. "Number 1" will appear at the time when the alarm goes off.
So far I've created scaffold: rails g scaffold Alarmclock alarm:time
I've added the "5" image to the index file by using an image for from a website: http://clareluffman.com/wp-content/uploads/2013/10/red-number-5.jpg
I'm assuming that the Alarmclock Controller should look something this :
def index
@alarmclocks = Alarmclock.all
@alarm_goes_off = Alarmclock.where(Time.now == [:alarm])
end
And the index.html.erb should have some if "alarm_goes_off" statements.... if this happens, display image "5". if this happens, display "4". Also, the page should be refreshing by itself. So I probably required some kind of cron job.
It's all in my head but I'm not sure how I should implement this.