Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Person.limit(10).joins("LEFT JOIN contacts ON contacts.contactable_id = people.id AND contacts.contactable_type= 'Person'").joins("Left JOIN (fields f INNER JOIN fields_strings fs_n ON f.field_id = fs_n.id ) ON field_type = 'Fields::String' AND (f.fieldable_type = 'Person' AND f.fieldable_id= people.id AND fs_n.key = 'first_name')").joins("INNER JOIN fields_strings fs_l ON field_type = 'Fields::String' AND (f.fieldable_type = 'Person' AND f.fieldable_id= people.id AND fs_l.key = 'last_name'").joins("INNER JOIN fields_strings fs_p ON f.field_id = fs_p.id ) ON field_type = 'Fields::String' AND (f.fieldable_type = 'Contact' AND f.fieldable_id= contacts.id AND fs_p.key = 'phone'")
- Person.joins("LEFT JOIN contacts ON contacts.contactable_id = people.id AND contacts.contactable_type= 'Person'").joins("INNER JOIN fields f ON field_type = 'Fields::String' AND ((f.fieldable_type = 'Person' AND f.fieldable_id= people.id) OR (f.fieldable_type = 'Contact' AND f.fieldable_id= contacts.id)) ").joins("INNER JOIN fields_strings fs_n ON f.field_id = fs_n.id AND fs_n.key = 'first_name'").joins("INNER JOIN fields_strings fs_l ON f.field_id = fs_l.id AND fs_l.key = 'last_name'").joins("LEFT JOIN fields_strings fs_p ON f.field_id = fs_p.id AND fs_p.key = 'phone'")
- Person.joins("LEFT JOIN contacts ON contacts.contactable_id = people.id AND contacts.contactable_type= 'Person'").joins("INNER JOIN fields f ON field_type = 'Fields::String' AND ((f.fieldable_type = 'Person' AND f.fieldable_id= people.id) OR (f.fieldable_type = 'Contact' AND f.fieldable_id= contacts.id)) ").joins("INNER JOIN fields_strings fs_n ON f.field_id = fs_n.id AND fs_n.key = 'first_name'").joins("INNER JOIN fields_strings fs_l ON f.field_id = fs_l.id AND fs_l.key = 'last_name'").joins("LEFT JOIN fields_strings fs_p ON f.field_id = fs_p.id AND fs_p.key = 'phone'")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement