在我的rails应用程序中,我有两个模型Student和StudentRecord。 student.rb has_many:student_records活跃记录中属性的比较
in student_records_controller我想搜索所有查询参数的所有学生的所有记录。学生记录的两个属性是date_recorded和状态。
因此,在一个特定的搜索中,我希望获得状态为“失败”的学生的最新记录,但前提是记录后没有“通过”记录。
scope = StudentRecord.join(:student)
.
.
.
#so a query something like the following
scope.where("status = ?", params[:search][:status]).having ....
您正在使用什么数据库? –
我正在使用Postgres – Tiamon