ÜberBaller
unread,Aug 20, 2009, 1:31:00 PM8/20/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 2dcJqgrid - Rails plugin
Hi, 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
# GET /oligos
# GET /oligos.xml
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?
return
end
paginate :page => page, :per_page => rows
order_by "#{sidx} #{sord}"
end
end
end