Another
имеет поле some_field
.
ThisTable
belongs_to
Another
и имеет поле local_field
.
Теперь я хотел бы написать область действия some_filter
для ThisTable
:
scope :some_filter, ->(var_in) {
tmp1 = calc_sth(another.some_field, var_in)
tmp2 = calc_sth_else(another.some_field, var_in)
where(local_field: tmp1..tmp2)
}
Я получил ошибку undefined local variable or method 'another' for #<ActiveRecord::AssociationRelation []>
Как написать это?