Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed Rails 3 deprecation warning

  • Loading branch information...
commit f6d9c3146a3f84932a3694a67a423907d4f1a570 1 parent ad1d901
@greenlynx authored
Showing with 13 additions and 2 deletions.
  1. +13 −2 lib/validatious-on-rails.rb
View
15 lib/validatious-on-rails.rb
@@ -8,6 +8,17 @@
module ValidatiousOnRails # :nodoc:
extend self
+
+ # Returns the environment of the Rails application,
+ # if this is running in a Rails context.
+ # Returns `nil` if no such environment is defined.
+ #
+ # @return [String, nil]
+ def rails_env
+ return ::Rails.env.to_s if defined?(::Rails.env)
+ return RAILS_ENV.to_s if defined?(RAILS_ENV)
+ return nil
+ end
# Standard error: Acts as base error class for the plugin.
#
@@ -19,7 +30,7 @@ def initialize(message)
end
RemoteValidationInvalid = ::Class.new(::ValidatiousOnRails::ValidatiousOnRailsError)
- @@verbose = ::Object.const_defined?(:RAILS_ENV) ? (::RAILS_ENV.to_sym == :development) : true
+ @@verbose = rails_env == nil ? true : (rails_env.to_sym == :development)
@@client_side_validations_by_default = true
@@remote_validations_enabled = false
@@ -36,4 +47,4 @@ def log(message, level = :info)
@@logger.send(level.to_sym, "[validatious-on-rails:] #{level.to_s.upcase} #{message}")
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.