1

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,

arkadiy kraportov
  • 3,679
  • 4
  • 33
  • 42

1 Answers1

7

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.

Chubas
  • 17,823
  • 4
  • 48
  • 48
  • 3
    Just found out how to get platform from JRuby: org.jruby.platform.Platform::OS or helpers like: org.jruby.platform.Platform::IS_WINDOWS. http://github.com/jruby/jruby/blob/master/src/org/jruby/platform/Platform.java – arkadiy kraportov Sep 14 '10 at 03:08