How would you store a business's hours in the db/model of a Rails app?

后端 未结 5 757
余生分开走
余生分开走 2021-01-31 05:43

I\'m creating a Rails app that will store the opening and closing hours for a business. Originally, I thought of simply using a text data type and letting it be free-form:

5条回答
  •  臣服心动
    2021-01-31 06:24

    Checkout these libraries for handling recurring dates.

    Once the recurrence is setup in an object say office_hours, in ice_cube you can query it as:

    office_hours.occurring_at?(Time.now)
    

提交回复
热议问题