Compara Time.now en Rails pero ignora el año?
Tengo el siguiente código en mi aplicación Rails 3:
scope :active, lambda {
where("starts_at <= ? AND ends_at >= ?", Time.now.utc, Time.now.utc)
}
scope :since, lambda { |hide_time|
where("updated_at > ? OR starts_at > ?", hide_time.utc, hide_time.utc) if hide_time
}
def self.display(hide_time)
active.since(hide_time)
end
Sin embargo, quiero devolver los resultados independientemente de si el año coincide con el año actual o no. Mientras el día y el mes coincidan, está bien. es posible?
losstarts_at
yends_at
las columnas sondatetime
formateado Así que incluirán automáticamente un año, incluso si no configuro uno en el formulario:
<%= f.datetime_select :starts_at, :order => [:day, :month], :discard_year => true %>
Cualquier indicador sería apreciada.