How to define a constant when running script/server?
Posted
by Zeke
on Stack Overflow
See other posts from Stack Overflow
or by Zeke
Published on 2010-04-06T23:38:03Z
Indexed on
2010/04/06
23:43 UTC
Read the original article
Hit count: 189
I want to start up my Rails development server like this:
script/server OFFLINE_MODE=1
and have a method that checks for the presence of that constant:
helper_method :offline_mode?
def offline_mode?
defined?(OFFLINE_MODE) ? true : false
end
so I can hide stuff in my app when I'm coding without access to the internet. For some reason though, OFFLINE_MODE doesn't ever seem to be defined and the method always returns false.. thoughts?
© Stack Overflow or respective owner