需要有关rails 4中动态表格内容计划的帮助

我需要你的帮助来计划我的想法。

首先,我向您展示我想要发布的内容:
![在此处输入图像说明] [1]
有一个html表,应该有一个上面的内容(标题日期,标题,时间,位置)。 如您所见,这是一个时间表。

模型:
有一个用户模型,它包含一个schedule-column作为数组,因为我不想使用关系行为。 所以我只想在这个数组中保存schedule-model-name。
此外,还有一个计划模型,其中包含日期,标题,时间,位置和访问的用户arrays。

对RoR专家的致辞:感谢belongs_to -suggestion,但我不明白,我必须在口语考试中解释我的决定,所以我只想用,我真正理解。

控制器:
处理对计划模型的访问,例如@all
我认为这对我没有任何问题。

视图:
这就是我需要你帮助的地方。
我搜索了类似“动态表格内容”的内容,发现了这个:
[从Ruby中的哈希数组生成一个HTML表格] [2],但我真的不明白他们的任何答案..

在输入这个问题时,我意识到我应该在Controller中做更多@all
一天进行多次预约也很重要。
如果时间相似或相同,则约会应平行显示。
如果时间不相似,则约会应相互显示。 (图中未显示)

我也希望有人能抽出时间帮忙。

你最好这样设置:

 #app/models/user.rb Class User < ActiveRecord::Base has_many :schedules end #app/models/schedule.rb Class Schedule < ActiveRecord::Base belongs_to :user end 

那么你的表可以这样构造:

 #schedules id | user_id | titel | location | time | created_at | updated_at 

这意味着你可以这样做:

 #config/routes.rb resources :users, only: :index #app/controllers/users_controller.rb def index @schedules = current_user.schedules end #app/views/users/index.html.erb <%= for schedule in @schedules do %> <%= schedule.titel %> <%= schedule.time %> <%= schedule.location %> <% end %> 

这将输出您的用户的计划/约会列表。 为了获得分组效果,您必须在控制器中使用group_by