【发布时间】:2013-07-23 10:11:37
【问题描述】:
目前附件是根据attachment_file_name、tags和employee_id搜索的,我也想根据员工姓名搜索,怎么办?
必须使用两个模型。
- 员工 - 包含员工姓名
- LessonplanAttachment - 包含员工的 ID。
代码部分。
def search_ajax
@attachments = LessonplanAttachment.find(:all,
:conditions => ["attachment_file_name LIKE ? OR tags LIKE ? OR employee_id = ?",
"#{params[:query]}%","#{params[:query]}%",params[:query]])
end
【问题讨论】:
-
如果您的班级获得未定义的方法
joins,您能否确认您使用的是什么版本的rails? -
rails 2,使用 rvm 1.8.7
标签: ruby-on-rails search join ruby-on-rails-2