mercredi 20 mai 2015

Apply an 'or' to an inner joined where clause ActiveRecord

Model:

class QueueList < ActiveRecord::Base
  has_many :times

  self.today
    joins(:times).where(times: { period_type: 'on', date: Date.today} || times: { period_type: 'from', date: Date.today }) 
  end
end

The above model contains a list of times. Because :times can be in two different period_types, I have to apply an "OR" to this query. Is there a way to accomplish the above faulty code without the usage of a string query as I am trying to do in ActiveRecord?

Aucun commentaire:

Enregistrer un commentaire