Commit 9917c631cdd26318b461b5d13d8a056e86e2cf18
1 parent
0db12ddd
Exists in
master
and in
23 other branches
Making sti work with namespaced models
Showing
2 changed files
with
18 additions
and
1 deletions
Show diff stats
config/environment.rb
| @@ -106,7 +106,7 @@ end | @@ -106,7 +106,7 @@ end | ||
| 106 | 106 | ||
| 107 | # Include your application configuration below | 107 | # Include your application configuration below |
| 108 | 108 | ||
| 109 | - | 109 | +ActiveRecord::Base.store_full_sti_class = true |
| 110 | 110 | ||
| 111 | Noosfero.locales = { | 111 | Noosfero.locales = { |
| 112 | 'en' => 'English', | 112 | 'en' => 'English', |
test/unit/environment_test.rb
| @@ -1140,4 +1140,21 @@ class EnvironmentTest < Test::Unit::TestCase | @@ -1140,4 +1140,21 @@ class EnvironmentTest < Test::Unit::TestCase | ||
| 1140 | end | 1140 | end |
| 1141 | end | 1141 | end |
| 1142 | 1142 | ||
| 1143 | + should 'not conflict to save classes with namespace on sti' do | ||
| 1144 | + class School; end; | ||
| 1145 | + class Work; end; | ||
| 1146 | + class School::Project < Article; end | ||
| 1147 | + class Work::Project < Article; end | ||
| 1148 | + | ||
| 1149 | + title1 = "Sample Article1" | ||
| 1150 | + title2 = "Sample Article2" | ||
| 1151 | + profile = fast_create(Profile) | ||
| 1152 | + | ||
| 1153 | + p1 = School::Project.new(:name => title1, :profile => profile) | ||
| 1154 | + p2 = Work::Project.new(:name => title2, :profile => profile) | ||
| 1155 | + | ||
| 1156 | + p1.save! | ||
| 1157 | + p2.save! | ||
| 1158 | + end | ||
| 1159 | + | ||
| 1143 | end | 1160 | end |