问题:我只想在学生/演出中仅显示即将到来的参加者(不是过去的)。通过控制器导轨依赖于过滤器的数据
我
- scaffold lesson name starts_at:datetime ends_at:datetime
,
- scaffold attendance student:references lesson:references
,
- scaffold student name
。
student has_many :attendances
,lesson has many :attendances
,student has_many :lessons, through: :attendances
我试图
students_controller.rb:
@future_attendances = @student.attendances.where('lesson.starts_at > ?', Time.now)
学生/ show.html.haml:
%table
%thead
%tr
%th Title
%th Starts at
%tbody
- @future_attendances.each do |attendance|
%tr
%td= attendance.lesson.name
%td= attendance.lesson.starts_at
但它不起作用。有任何想法吗?
您是否收到任何错误? – Uzbekjon
什么“不起作用”呢?是否显示过去的参加人数,路线是否中断,是否显示错误等 – PhilVarg
'SQLite3 :: SQLException:no such column:lesson.starts_at:SELECT“attendances”。* FROM“attendances”WHERE“attendances”。“student_id”=? AND(lesson.starts_at>'2016-04-20 22:07:13.208768')' –