How to check rails environment?

One liner if you are in app root

rails r "puts Rails.env"


It sounds like you tried to run Rails.env in a shell. That won't work because Rails.env is Ruby code, not a Unix shell command.

How are you deploying and starting your rails app on the server? The Rails environment is determined by whatever the value of the RAILS_ENV environment variable is when the server starts. You might have some configuration file somewhere that specifies it, or maybe you just start your server with a command of the form RAILS_ENV=production my_rails_server? I would need to know more details about exactly what commands you run to start the server in order to really answer this. Are you using unicorn, mongrel, Webrick, or something else?


You can check complete details about your rails app. By typing this command "rake about". Will give you brief details about which version of ruby have you installed on your machine, rails version etc. For example -

About your application's environment

Rails version ------> 4.2.6

Ruby version ------> 2.3.1-p112 (x86_64-linux)

RubyGems version ----> 2.5.1

Rack version ----> 1.6.4

JavaScript Runtime -------> Node.js (V8)

Middleware ------> Rack::Sendfile, ActionDispatch::Static,

Application root ----> /data/www/testapp

Environment ------> development

Database adapter -----> mysql2

Database schema version -----> 0


On your Rails Application directory type :

rake about