Skip to content

Instantly share code, notes, and snippets.

@svs
Created December 16, 2012 21:07
Show Gist options
  • Save svs/4313089 to your computer and use it in GitHub Desktop.
Save svs/4313089 to your computer and use it in GitHub Desktop.
params example 1
class FooController < ApplicationController
def index
search_params = (params[:quotation] || {}).select{|k,v| !v.blank?}
q = search_params.delete("user")
if q
q = "%#{q}%"
search_params[:intended_trip] = {:user => {:conditions => ['email ilike ? or first_name ilike ? or last_name ilike ? or mobile_number ilike ?', q, q, q, q]}}
end
if params[:all]
@quotations = Quotation.all(search_params)
else
@quotations = Quotation.active(search_params)
end
if (params[:quotation][:workflow_state] rescue nil) == "callback"
@quotation_ids = @quotations.all(:workflow_state => "callback", :order => :callback_at.desc).aggregate(:id)
@poolability_scores = PoolabilityScore.all(:quotation_id => @quotations_ids).page(params[:page])
@count = @quotation_ids.count
else
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment