search for: find_wher

Displaying 8 results from an estimated 8 matches for "find_wher".

Did you mean: find_where
2008 May 19
0
changed to will_paginate
Hi Till now we used the rails pagination.But now onwards shifting to will_paginate The code I use currently is as below .This is with the help of find_where pluggin..A fantastic pluggin which we still want to use...I would like to know how can i modify the following code to work with will_paginate step 1: set the variables you''ll need page = (params[:page] ||= 1).to_i items_per_page = 20 offset = (page -...
2008 Mar 06
1
pagination for an object array
...iables you''ll need page = (params[:page] ||= 1).to_i items_per_page = 20 offset = (page - 1) * items_per_page # step 2: instead of performing the full find, just find the record count @search_sd_ticket_count_result = ServiceDeskTicket.find_where(:all,:select=>''count(*) as count1'' ) do |sd| sd.number.downcase =~ "%"+@sd_ticket_number.downcase+"%" if !@sd_ticket_number.nil? sd.name== @sd_ticket_name...
2008 Apr 26
0
moving pagination code to model
...es you''ll need page = (params[:page] ||= 1).to_i items_per_page = 20 offset = (page - 1) * items_per_page # step 2: instead of performing the full find, just find the record count @search_sd_ticket_count_result = ServiceDeskTicket.find_where(:all,:select=>''count(*) as count1'' ) do |sd| end record_count=@search_sd_ticket_count_result[0].count1.to_i # step 3: create a Paginator, the second variable has to be the number of ALL items on all pages...
2006 Jun 14
6
find and LIKE ''xxx%'' clause
Hi there ! I try to figure out how to do something like this in Rails : SELECT * FROM my_table WHERE name LIKE ''GOGONAM%'' My problem is the % and the quotes. >From now, I do like this : searched_name = params[:name]+''%'' user = MyTable.find(:all, :conditions => ["name LIKE ?", searched_name]) But is there a more gracefull way to do a LIKE
2006 Jun 30
3
New release of ez-where plugin
...expect. So you can use blocks and ruby ops for very complex conditions. Here is a teaser: # find all articles with title, body or extended LIKE "%#{params [:search]}%" # AND (author.name = params[:author] OR comment.body LIKE "%#{params [:search]}%") @articles = Article.find_where(:all, :include => [:author, { :comments => :users }]) do |article, author, comment| article.any_of(:title, :body, :extended) =~ "%#{params[:search]}%" any { author.name == params[:author] comment.body =~ "%#{params[:search]}%" } end =>[&quo...
2006 Aug 07
2
Dynamically created queries
Hello, I am having difficulty dynamically building a query. I want to ensure that I''m using Active Record protection against SQL injection attacks. In PHP land, I would have built up the query in my logic & attempted to clean every variable - a bit tedious really. I want to be able to achieve something like: events = Event.find(:all, :conditions => [**DynamicallyBuiltQuery**
2006 Jul 02
18
JOIN conditions
Hi, how can I get Rails to generate SQL queries with conditions in the JOIN clause? What I would want is: SELECT * FROM people p LEFT OUTER JOIN jobs j (p.job_id = j.id AND j.salary > 9999999) I tried People.find(:all, :include => ''jobs'', :conditions => ''jobs.salary > 9999999'') but that generates SELECT * FROM people p LEFT OUTER
2006 Jun 19
6
SQL Search Qustion
I am working on writing a search method where a user can type a string of words and I return all the objects that have fields that match all of the words in one or a combination of fields. Person first_name last_name Pet name Person has_many :pets I want to write some SQL so that if I search for "Tony AAAA" I will get all the people who have Tony and AAA either in their