Sha256: e8e72137782944423e1ba2b8964e1393ecadde39adbd879d3ae926642f8ad5cb
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
class LookingForController < ApplicationController def search object_eval = eval("#{params[:object_name]}") if params[:looking_for_filter] params[:looking_for_filter].each do |key, value| if value!="" table_alias_and_field = key table_alias_and_field = "#{params[:object_name].underscore}.#{key}" if key.split('.').length == 1 ar = table_alias_and_field.split('.') table_alias = ar[ar.length-2] field = ar[ar.length-1] table_alias = table_alias.pluralize table_alias_and_field = "#{table_alias}.#{field}" if params[:no_case] && params[:no_case].include?(key) object_eval = object_eval.where("upper(#{table_alias_and_field}) like ? ",value.upcase+"%") elsif params[:use_upper] && params[:use_upper].include?(key) object_eval = object_eval.where("#{table_alias_and_field} like ? ",value.upcase+"%") else object_eval = object_eval.where("#{table_alias_and_field} like ? ",value+"%") end end end end if params[:conditions] && params[:conditions].class == Array params[:conditions].collect! do |a| if a=='true' true elsif a=='false' false else a end end end object_eval = object_eval.where(params[:conditions])if params[:conditions] object_eval = object_eval.includes(params[:include]) if params[:include] @records = object_eval.paginate(:per_page => 10,:page => params[:page]).order(params[:order]) template = 'looking_for' template = 'assign_first' if @records.length == 1 && params[:validate] == 'true' template = 'clear' if params[:clear] == 'true' respond_to do |format| format.js { render template} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
looking_for-0.2.0 | app/controllers/looking_for_controller.rb |