Skip to content

Instantly share code, notes, and snippets.

@aredridel
Created December 23, 2010 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aredridel/753341 to your computer and use it in GitHub Desktop.
Save aredridel/753341 to your computer and use it in GitHub Desktop.
typetable = Account.reflections[@input.type.intern].table_name
@accounts = @accounts.joins(@input.type)
@accounts.where(Contact.p(:id)).where(
Arel::Nodes::Grouping.new @accounts = [:first, :last, :company, :name].inject(@accounts) { |a,e|
Arel::Nodes::Or.new(a, Contact.p(e).matches("%#{@input.q}%"))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment