Скажем, у меня есть модель Post со многими авторами через модель AuthorAssignment:
class Post < ActiveRecord::Base
has_many :author_assignments, :dependent => :destroy
has_many :authors, :through => :author_assignments
has_many :featured_authors, :through => :author_assignments, :conditions => "`author_assignments`.featured = 1"
end
Вот моя проблема:
Когда я звоню:
@post.featured_author_ids
В SQL-запрос не входит мое условие, что author_assignments.feature равно true.
SELECT `author_assignments`.author_id FROM `author_assignments` WHERE (`author_assignments`.post_id = X)
С другой стороны, когда я звоню:
@post.featured_authors
Условие включено вSQL и ожидаемый результат верны.
Мысли?