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
|
end
|
||||||
|
|
||||||
def env
|
def env
|
||||||
if rails_env = (defined?(::Rails) ? ::Rails.env : (defined?(RAILS_ENV) ? RAILS_ENV : nil))
|
env_production? ? :production : :development
|
||||||
rails_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
|
||||||
end
|
end
|
||||||
|
|
||||||
def root
|
def root
|
||||||
if defined?(::Rails)
|
if defined?(::Rails) && ::Rails.respond_to?(:root)
|
||||||
::Rails.root
|
::Rails.root
|
||||||
elsif defined?(RAILS_ROOT)
|
elsif defined?(RAILS_ROOT)
|
||||||
RAILS_ROOT
|
RAILS_ROOT
|
||||||
|
Loading…
Reference in New Issue
Block a user