aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/model_schema.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-12-13 12:35:24 +0900
committerGitHub <noreply@github.com>2017-12-13 12:35:24 +0900
commit293401809dc597a61e46843019ee8be6ce731429 (patch)
tree17f8cfed3bfbab1532040b7bd2a61bbde6466b63 /activerecord/lib/active_record/model_schema.rb
parent9d43a84f73c1b3853a91d052a462ee60eccaf957 (diff)
parent011e641d19d235e4ec03fd9eb20ecea644ec5e06 (diff)
downloadrails-293401809dc597a61e46843019ee8be6ce731429.tar.gz
rails-293401809dc597a61e46843019ee8be6ce731429.tar.bz2
rails-293401809dc597a61e46843019ee8be6ce731429.zip
Merge pull request #31423 from bogdanvlviv/fix-protected_environments-with-symbols
Fix protected environments with symbols
Diffstat (limited to 'activerecord/lib/active_record/model_schema.rb')
-rw-r--r--activerecord/lib/active_record/model_schema.rb30
1 files changed, 16 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb
index 1941d3d5ea..773b0f6cde 100644
--- a/activerecord/lib/active_record/model_schema.rb
+++ b/activerecord/lib/active_record/model_schema.rb
@@ -87,19 +87,6 @@ module ActiveRecord
# Sets the name of the internal metadata table.
##
- # :singleton-method: protected_environments
- # :call-seq: protected_environments
- #
- # The array of names of environments where destructive actions should be prohibited. By default,
- # the value is <tt>["production"]</tt>.
-
- ##
- # :singleton-method: protected_environments=
- # :call-seq: protected_environments=(environments)
- #
- # Sets an array of names of environments where destructive actions should be prohibited.
-
- ##
# :singleton-method: pluralize_table_names
# :call-seq: pluralize_table_names
#
@@ -122,9 +109,9 @@ module ActiveRecord
class_attribute :table_name_suffix, instance_writer: false, default: ""
class_attribute :schema_migrations_table_name, instance_accessor: false, default: "schema_migrations"
class_attribute :internal_metadata_table_name, instance_accessor: false, default: "ar_internal_metadata"
- class_attribute :protected_environments, instance_accessor: false, default: [ "production" ]
class_attribute :pluralize_table_names, instance_writer: false, default: true
+ self.protected_environments = ["production"]
self.inheritance_column = "type"
self.ignored_columns = [].freeze
@@ -238,6 +225,21 @@ module ActiveRecord
(parents.detect { |p| p.respond_to?(:table_name_suffix) } || self).table_name_suffix
end
+ # The array of names of environments where destructive actions should be prohibited. By default,
+ # the value is <tt>["production"]</tt>.
+ def protected_environments
+ if defined?(@protected_environments)
+ @protected_environments
+ else
+ superclass.protected_environments
+ end
+ end
+
+ # Sets an array of names of environments where destructive actions should be prohibited.
+ def protected_environments=(environments)
+ @protected_environments = environments.map(&:to_s)
+ end
+
# Defines the name of the table column which will store the class name on single-table
# inheritance situations.
#