Can you do greater than comparison on a date in a Rails 3 search?
Can you do greater than comparison on a date in a Rails 3 search?
Rails3 command:
Note. where(:user_id => current_user.id, :notetype => p[:note_type]). where("date > ?", p[:date]). order('date ASC, created_at ASC')
Convert everything into the SQL notation:
Note. where("user_id = ? AND notetype = ? AND date > ?", current_user.id, p[:note_type], p[:date]). order('date ASC, created_at ASC')
Hit problems where column names are ambiguous:
date_field = Note.arel_table[:date] Note.where(user_id: current_user.id, notetype: p[:note_type]). where(date_field.gt(p[:date])). order(date_field.asc(), Note.arel_table[:created_at].asc())