diff --git a/lib/nested_has_many_through/association.rb b/lib/nested_has_many_through/association.rb index 9cb3b06..9ddfca8 100644 --- a/lib/nested_has_many_through/association.rb +++ b/lib/nested_has_many_through/association.rb @@ -98,7 +98,7 @@ def construct_has_many_or_belongs_to_attributes(reflection, association_class, t # Add type_condition, if applicable conditions += " AND #{association_class.send(:type_condition).to_sql}" if association_class.finder_needs_type_condition? # Add custom conditions - conditions += " AND (#{association_class.send(:sanitize_sql, reflection.options[:conditions])})" if reflection.options[:conditions] + conditions += " AND (#{interpolate_and_sanitize_sql(reflection.options[:conditions], nil, association_class)})" if reflection.options[:conditions] if reflection.macro == :belongs_to if reflection.options[:polymorphic] diff --git a/spec/rails_app/app/models/author.rb b/spec/rails_app/app/models/author.rb index f56c0c1..e07c4db 100644 --- a/spec/rails_app/app/models/author.rb +++ b/spec/rails_app/app/models/author.rb @@ -1,5 +1,5 @@ class Author < User - has_many :posts + has_many :posts, :conditions => proc{ "1=1" } has_many :sources has_many :categories, :through => :posts has_many :similar_posts, :through => :categories, :source => :posts