arkadiy kraportov
arkadiy kraportov

Reputation: 3729

How Rails app can find out which OS it's running on

Some of development is done on Linux, some on Windows. Depending on which OS the app is currently running on, it needs to load different config files.

Is there any "Rails way" to do so?

Thanks,

Upvotes: 1

Views: 1618

Answers (1)

Chubas
Chubas

Reputation: 18043

You can use the Ruby constant RUBY_PLATFORM

The only gotcha is on JRuby, which lists "java" as the RUBY_PLATFORM, no matter which OS it is. On windows there is win32, mingw32 or cygwin.

Another solution is to use the sys_uname package from the sysutils gem, if the method above doesn't fit your needs.

Upvotes: 7

Related Questions