aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorwangjohn <wangjohn@mit.edu>2013-08-24 04:11:18 -0400
committerwangjohn <wangjohn@mit.edu>2013-08-24 23:28:40 -0400
commitbac384e85f6c4232a2ffcd9829d18896fc422e89 (patch)
tree193617aba59255d96e0f174587cf36039b7ea36a /activerecord/lib/active_record
parent539180cf8edaa405928162644dc617b4c179edff (diff)
downloadrails-bac384e85f6c4232a2ffcd9829d18896fc422e89.tar.gz
rails-bac384e85f6c4232a2ffcd9829d18896fc422e89.tar.bz2
rails-bac384e85f6c4232a2ffcd9829d18896fc422e89.zip
Removing instances of string class_names in fixtures.
Also, constantizing the default_fixture_model_name when it gets loaded in from the file. Later, when the class_name is passed to a new FixtureSet, a deprecation warning will occur if the class_name is a string.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/fixtures.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index eb89e3875f..a7a40ca72b 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -455,7 +455,7 @@ module ActiveRecord
fixtures_map[fs_name] = new( # ActiveRecord::FixtureSet.new
connection,
fs_name,
- class_names[fs_name] || default_fixture_model_name(fs_name),
+ class_names[fs_name] || (default_fixture_model_name(fs_name).safe_constantize),
::File.join(fixtures_directory, fs_name))
end
@@ -504,11 +504,14 @@ module ActiveRecord
@name = name
@path = path
+ if class_name.is_a?(String)
+ ActiveSupport::Deprecation.warn("The ability to pass in strings as a class name will be removed in Rails 4.2, consider using the class itself instead.")
+ end
+
if class_name.is_a?(Class) # TODO: Should be an AR::Base type class, or any?
@model_class = class_name
else
- ActiveSupport::Deprecation.warn("The ability to pass in strings as a class name will be removed in Rails 4.1, consider using the class itself instead.")
- @model_class = class_name.constantize rescue nil
+ @model_class = class_name.safe_constantize if class_name
end
@connection = ( model_class.respond_to?(:connection) ?