开发者

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

开发者 https://www.devze.com 2023-01-15 11:13 出处:网络
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 f开发者_JAVA技巧iles.

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 f开发者_JAVA技巧iles.

Is there any "Rails way" to do so?

Thanks,


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消