aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorEdouard CHIN <edouard.chin@shopify.com>2019-07-10 23:30:44 +0200
committerEdouard CHIN <edouard.chin@shopify.com>2019-07-16 14:28:38 +0200
commitd204a09df21ce3578081108936a57707b5ece9b8 (patch)
tree48d3e64b8c480e13a6c538ff1cf84d50d713131c /activemodel/lib
parentb677adede027eefed41f6b37096df7bbc4eb3d38 (diff)
downloadrails-d204a09df21ce3578081108936a57707b5ece9b8.tar.gz
rails-d204a09df21ce3578081108936a57707b5ece9b8.tar.bz2
rails-d204a09df21ce3578081108936a57707b5ece9b8.zip
Switch to use `class_attribute`:
- Since `ActiveModel::Error` can now be inherited by `ActiveModel::NestedError`, when the latter generates a `full_message`, the `i18n_customize_full_message` accessor set in the parent class is not set. This commit fixes that by using a `class_attribute` instead.
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/error.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/activemodel/lib/active_model/error.rb b/activemodel/lib/active_model/error.rb
index aef28b5af0..6deab3578d 100644
--- a/activemodel/lib/active_model/error.rb
+++ b/activemodel/lib/active_model/error.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require "active_support/core_ext/class/attribute"
+
module ActiveModel
# == Active \Model \Error
#
@@ -8,10 +10,7 @@ module ActiveModel
CALLBACKS_OPTIONS = [:if, :unless, :on, :allow_nil, :allow_blank, :strict]
MESSAGE_OPTIONS = [:message]
- class << self
- attr_accessor :i18n_customize_full_message # :nodoc:
- end
- self.i18n_customize_full_message = false
+ class_attribute :i18n_customize_full_message, default: false
def self.full_message(attribute, message, base_class) # :nodoc:
return message if attribute == :base