我的任务是选择搜索那些名字以参数值和所选值中的城市开头的学生。如何在 ruby on rails 中设置?我确实喜欢这个,但这不是工作控制器
def list
studentcount=Student.count()
puts studentcount
@studentname = Student.where("name name1 AND city = :cityId1",
{:name1 => params[:name], :cityId1 => params[:cityId]})
puts 'studentname'
puts @studentname.inspect
@students = Student.limit(params[:jtPageSize]).offset(params[:jtStartIndex]).order(params[:jtSorting])
@jtable = {'Result' => 'OK','Records' => @students.map(&:attributes), :TotalRecordCount => studentcount}
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @jtable}
end
end