Check if Rails module responds to env and root before using them
This commit is contained in:
parent
1bd156e88f
commit
c4a315af3c
@ -21,13 +21,19 @@ module Compass
|
||||
end
|
||||
|
||||
def env
|
||||
if rails_env = (defined?(::Rails) ? ::Rails.env : (defined?(RAILS_ENV) ? RAILS_ENV : nil))
|
||||
rails_env.production? ? :production : :development
|
||||
env_production? ? :production : :development
|
||||
end
|
||||
|
||||
def env_production?
|
||||
if defined?(::Rails) && ::Rails.respond_to?(:env)
|
||||
::Rails.env.production?
|
||||
elsif defined?(RAILS_ENV)
|
||||
RAILS_ENV == "production"
|
||||
end
|
||||
end
|
||||
|
||||
def root
|
||||
if defined?(::Rails)
|
||||
if defined?(::Rails) && ::Rails.respond_to?(:root)
|
||||
::Rails.root
|
||||
elsif defined?(RAILS_ROOT)
|
||||
RAILS_ROOT
|
||||
|
Loading…
Reference in New Issue
Block a user