开发者

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 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜