Skip to content

Instantly share code, notes, and snippets.

@kstevens715
Created August 19, 2016 19:58
Show Gist options
  • Select an option

  • Save kstevens715/97f00bab895b3d3bf25c94d86df74709 to your computer and use it in GitHub Desktop.

Select an option

Save kstevens715/97f00bab895b3d3bf25c94d86df74709 to your computer and use it in GitHub Desktop.
class UserIdentity
def cas_attachments
sql = id_column.in(cas_attachment_belongs_to_my_cas).or(id_column.in(cas_attachment_belongs_to_my_programs))
CasAttachment.where(sql)
end
def table
CasAttachment.arel_table
end
def cas_attachment_belongs_to_my_cas
CasAttachment.for_cas(cas).select(:id).ast
end
def cas_attachment_belongs_to_my_programs
CasAttachment.for_program(programs.select(:id)).select(:id).ast
end
def id_column
table[:id]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment