I posted this on the 2dcjqgrid group but maybe I'm better off here.
http://groups.google.com/group/2dcjqgrid/browse_thread/thread/ad4115ed1bca2050
I'm fairly new to rails and am having a bit of trouble moving my jqgrid code from the controller to the model. It worked fine in the controller. I know that the model can't use params so I'm passing those into a method, but when I look at the sql query it is not passing all the arguements. TIA for any help.
class OligosController < ApplicationController def index oligos = Oligo.search( params[:freezer], params[:cane], params [:box], params[:boxname], params[:slot], params[:oligoname], params [:sequence], params[:page], params[:sidx], params[:sord], params [:rows], params[:_search] ) respond_to do |format| format.html format.json { render :json => oligos.to_jqgrid_json ([:id,:freezer,:cane,:box,:boxname,:slot,:oligoname,:sequence],
params [:page], params[:rows], oligos.total_entries) } end end end
class Oligo < ActiveRecord::Base def self.search(freezer, cane, box, boxname, slot, oligoname, sequence, page, sidx, sord, rows, _search) find(:all) do if _search == "true" freezer =~ "%#{freezer}%" if freezer.present? cane =~ "%#{cane}%" if cane.present? box =~ "%#{box}%" if box.present? boxname =~ "%#{boxname}%" if boxname.present? slot =~ "%#{slot}%" if slot.present? oligoname =~ "%#{oligoname}%" if oligoname.present? sequence =~ "%#{sequence}%" if sequence.present? end paginate :page => page, :per_page => rows order_by "#{sidx} #{sord}" end end end
The original code can be found here.... http://www.2dconcept.com/jquery-grid-rails-plugin