# Controlling when an application is open?

**URL:** <https://www.ruby-forum.com/t/controlling-when-an-application-is-open/106390>\
**Category:** Rails\
**Created:** [June 9, 2007, 4:48pm UTC](https://www.ruby-forum.com/t/controlling-when-an-application-is-open/106390 "2007-06-09T16:48:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [June 9, 2007, 4:48pm UTC](https://www.ruby-forum.com/t/controlling-when-an-application-is-open/106390/1 "2007-06-09T16:48:07Z")

</div>

I’m trying to figure out how to limit the dates an application runs. I  
have a table with “from” and “to” columns. What I would like is for my  
application to check these dates when it first starts up, and perform  
actions depending on whether the current date falls within that range.  
For instance, let’s say I want my application to only be running during  
the summertime, from June 1 to August 31. In my table, I would have  
“from” as 6/1/07 and “to” as 8/31/07. I want the application to check  
the current date (6/9/07) and, if the date falls within the given time  
(which it does), I would like it to run the application as normal.  
Otherwise, if it doesn’t fall within that date range, it redirects to  
another page telling the user that the application is down/not running,  
etc. Does RoR have an easy way to do this? I searched a few forums and  
googled some things, but couldn’t find anything. I’m not sure if this  
is something a normal application does. If anyone has any suggestions  
or thoughts, I’d greatly appreciate them. Thanks.

---

<div class="post-metadata">

**Author:** ![liberte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@liberte](https://www.ruby-forum.com/u/liberte)\
**Post date:** [June 10, 2007, 2:55pm UTC](https://www.ruby-forum.com/t/controlling-when-an-application-is-open/106390/2 "2007-06-10T14:55:20Z")

</div>

In application controller:  
before\_filter ( :can\_run\_this\_date }

def can\_run\_this\_date  
if date\_range.include?(Time.now) # this line doesn’t work, but it  
should be something similair  
…  
else  
…  
end  
end

Sorry I couldn’t help anymore, Good luck though.

Cheers,  
Zach I.  
â†’ Blog – [http://www.zachinglis.com](http://www.zachinglis.com)  
â†’ Company – [http://www.lt3media.com](http://www.lt3media.com)  
â†’ Portfolio – [http://portfolio.zachinglis.com](http://portfolio.zachinglis.com)
