Rails - 按2个日期列分组

时间:2016-12-09 12:28:19

标签: ruby-on-rails postgresql datetime group-by

使用Rails和PostgreSQL如何按两个DATETIME列进行分组?

我想根据企业的工作日格式化字符串

例如:周一至周五10:00-22:00,SAT-SUN 10:00 - 18:00

我有这个模型

# == Schema Information
#
# Table name: establishment_open_hours
#
#  id                  :integer          not null, primary key
#  weekday             :string
#  opens_at            :datetime
#  closes_at           :datetime
#  openable_hours_id   :integer
#  openable_hours_type :string
#  created_at          :datetime
#  updated_at          :datetime
#

class Establishment::OpenHour < ActiveRecord::Base
  belongs_to :openable_hours, polymorphic: true
end

0 个答案:

没有答案