Get sinatra environment from within instance method

pguardiario picture pguardiario · Nov 19, 2011 · Viewed 9.4k times · Source

What's the proper way to determine the environment? Right now I'm using:

class Main < Sinatra::Base
    get '/' do
        puts self.class.development?
        puts self.class.production?
    end
end

But it doesn't seem right.

Answer

Jim Deville picture Jim Deville · Nov 19, 2011

I would use Sinatra::Base.development? or Sinatra::Base.production? since that is where the methods are coming from.