Rails的时间表应用程序4

时间:2016-04-15 08:56:09

标签: ruby-on-rails ruby-on-rails-4

我正在尝试构建一个与我的某个模型配合使用的时间表设置。在我陈述我的问题之前,我将给出一些问题的背景。

我有一个名为约会的模型,其中包含以下列:

Name(String)
Start_time(time)
End_time(time)
Appt_Date(date)

现在我可以在1天内完成多次约会。

例如,让我们说我有以下2个约会对象:

Appointment 1: 
Name: Makeup Appointment
Start_time: 11:00 am
End_time: 1:00 pm
Date: March 30, 2016

Appointment 2: 
Name: Daily Meetup
Start-time: 2:00 pm
End_time: 3:00 pm
Date: March 30, 2016

我想实现一个日期选择器表单,您可以在其中选择一个日期,它将呈现24行(每天每小时1行),并根据该约会上的约会填写时间不可用的行天。

例如,如果我从日期选择器中选择2016年3月30日,我想渲染24行并将行显示为上午11点到下午1点和下午2点到3点。

设置就像谷歌日历(时间段如何着色),但每天都有。我不需要能够编辑这些行。我只需要查看它们,并根据特定日期的约会对象使用彩色单元格进行渲染。

我的问题是,我不知道从哪里开始能够设计与约会对象交互的这24行。我在想,也许我会构建一个辅助方法,但即使我很丢失。我会很感激如何处理这个问题。

1 个答案:

答案 0 :(得分:0)

以下将帮助您:

    1.Create  a file in initializer which contains list of available time slots like 10 am to 10 pm.
    2.For displaying date time field , use some jquery date time picker plugin.
    3.Fire an ajax when clicked on datetime picker.
    4.Ajax request will come on the controller & where you have to create an active record query which will fetch all apointments according to the particular date.
    5.MAke an array variable & store the time which are already booked in the above appointments.
    6.Compare the available time with the booked time & edit datetimepikcer.js to shaded the booked date.