From 9917c631cdd26318b461b5d13d8a056e86e2cf18 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Mon, 20 Jun 2011 11:47:52 -0300 Subject: [PATCH] Making sti work with namespaced models --- config/environment.rb | 2 +- test/unit/environment_test.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config/environment.rb b/config/environment.rb index 8366277..534ecf4 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -106,7 +106,7 @@ end # Include your application configuration below - +ActiveRecord::Base.store_full_sti_class = true Noosfero.locales = { 'en' => 'English', diff --git a/test/unit/environment_test.rb b/test/unit/environment_test.rb index c5000e8..f8d8c86 100644 --- a/test/unit/environment_test.rb +++ b/test/unit/environment_test.rb @@ -1140,4 +1140,21 @@ class EnvironmentTest < Test::Unit::TestCase end end + should 'not conflict to save classes with namespace on sti' do + class School; end; + class Work; end; + class School::Project < Article; end + class Work::Project < Article; end + + title1 = "Sample Article1" + title2 = "Sample Article2" + profile = fast_create(Profile) + + p1 = School::Project.new(:name => title1, :profile => profile) + p2 = Work::Project.new(:name => title2, :profile => profile) + + p1.save! + p2.save! + end + end -- libgit2 0.21.2