Browse files

fixed should_have_many :through bug #60, and added .svn to gitignore.

  • Loading branch information...
1 parent cefcfe1 commit 2cb29f5e6daf217299296282e753b5f0bef9ff37 Tammer Saleh committed Jul 31, 2008
Showing with 5 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +4 −1 lib/shoulda/active_record_helpers.rb
View
1 .gitignore
@@ -1,3 +1,4 @@
test/rails_root/log/*.log
doc
coverage
+.svn/
View
5 lib/shoulda/active_record_helpers.rb
@@ -372,7 +372,10 @@ def should_have_many(*associations)
assert reflection, "#{klass.name} does not have any relationship to #{association}"
assert_equal :has_many, reflection.macro
- associated_klass = (reflection.options[:class_name] || association.to_s.classify).constantize
+ associated_klass_name = reflection.options[:class_name]
+ associated_klass_name = reflection.options[:source].to_s.classify if associated_klass_name.blank?
+ associated_klass_name = association.to_s.classify if associated_klass_name.blank?
+ associated_klass = associated_klass_name.constantize
if through
through_reflection = klass.reflect_on_association(through)

0 comments on commit 2cb29f5

Please sign in to comment.