search for: field_ids_with_children

Displaying 1 result from an estimated 1 matches for "field_ids_with_children".

2012 Apr 17
0
Request for adding an "alias"/"as" to ActiveRecord
...has_children: field.children.exists? # Field.has_many :children, class: ''Field'', foreign_key: ''parent_id'' } But this means fields.count "select 1 where exists(...)" queries. This works fine, but I''d prefer to have something like this: field_ids_with_children = Field.find_by_sql([''select id from condition_type f1 where id in (?) and exists(select 1 from condition_type where parent_id=f1.id)'', fields.map(&:id)]).map(&:id) And then have something like "has_children: field_ids_with_children.include? field.id". But i...