Reputation: 55012
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.
Upvotes: 16
Views: 10135
Reputation: 21617
puts Sinatra::Application.environment
#=> production (or test, development)
Upvotes: 2
Reputation: 9110
self.class.development?
should actually work. These all work for me on Sinatra 1.3.1:
class Main < Sinatra::Base
get '/' do
puts Main.development?
puts self.class.development?
puts settings.development?
puts settings.environment == :development
end
end
Upvotes: 23
Reputation: 10672
I would use Sinatra::Base.development?
or Sinatra::Base.production?
since that is where the methods are coming from.
Upvotes: 33