From c9789d252d575853ed99e2d051cd84486c27ee5d Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 5 Sep 2013 14:38:43 -0700 Subject: only construct the FixtureSet with AR models --- activerecord/lib/active_record/fixtures.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/fixtures.rb') diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 07a7621c40..e71cbee8d7 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -443,7 +443,16 @@ module ActiveRecord end def [](fs_name) - @class_names[fs_name] ||= default_fixture_model(fs_name, @config).safe_constantize + @class_names.fetch(fs_name) { + klass = default_fixture_model(fs_name, @config).safe_constantize + + # We only want to deal with AR objects. + if klass && klass < ActiveRecord::Base + @class_names[fs_name] = klass + else + @class_names[fs_name] = nil + end + } end private @@ -574,7 +583,7 @@ module ActiveRecord rows[table_name] = fixtures.map do |label, fixture| row = fixture.to_hash - if model_class && model_class < ActiveRecord::Base + if model_class # fill in timestamp columns if they aren't specified and the model is set to record_timestamps if model_class.record_timestamps timestamp_column_names.each do |c_name| -- cgit v1.2.3