ruby on rails 3 - RoR Search conditions comparing two columns -
what want following:
a = assignment.all(:conditions => { :end_date < :start_date }) i want select records on end_date before start_date.
i don't want ending writing a
for each, push array if end_date earlier start_date.
how can achieve in pretty 'railsy'-way?
thank in advance.
edit:
i think problem comparing values of both columns. (allmost) every query comparing cell-value input-value.
shot in dark, maybe 1 in right direction ?
haven't figured out solution.
it's been while here nevertheless, can use areltable method:
t = assignment.arel_table assignment.where(t[:end_date].lt(t[:start_date])) the condition predicates documentation: http://www.rubydoc.info/github/rails/arel/arel/predications
the areltable documentation: http://www.rubydoc.info/github/rails/arel/arel/table
and guide: http://jpospisil.com/2014/06/16/the-definitive-guide-to-arel-the-sql-manager-for-ruby.html
Comments
Post a Comment