0

从我尝试“缺少 FROM 子句条目”的查询中获取以下错误

基本上,我的问题有很多答案,我试图获得属于“x”类别问题的所有答案

Answer.joins(:question).
from('answers').
where(:question => {:category => @category}).
sort_by(&:created_at).
reverse.
paginate(:page => params[:page], :per_page => 20)
4

1 回答 1

1

尝试:

Answer.joins(:question => :category).where...

怎么样:

Answer.joins(question: category).where("categories.name = ?", @category).order("answers.created at ASC").paginate(page: params[:page], per_page: 20)
于 2013-02-15T21:39:55.660 回答