<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Implementing Search in Ruby on Rails</title>
	<atom:link href="http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/</link>
	<description>Affiliate marketing, Internet marketing, web development, and small business ideas.</description>
	<lastBuildDate>Thu, 18 Mar 2010 09:50:41 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Hans</title>
		<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/comment-page-1/#comment-89367</link>
		<dc:creator>Hans</dc:creator>
		<pubDate>Thu, 18 Mar 2010 09:50:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=20#comment-89367</guid>
		<description>@darren: Why do think, that it is not necessary to split up &#039;query&#039; and check against each word of it?</description>
		<content:encoded><![CDATA[<p>@darren: Why do think, that it is not necessary to split up &#8216;query&#8217; and check against each word of it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: erwin</title>
		<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/comment-page-1/#comment-87756</link>
		<dc:creator>erwin</dc:creator>
		<pubDate>Sat, 09 Jan 2010 15:43:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=20#comment-87756</guid>
		<description>how you did implement your view?</description>
		<content:encoded><![CDATA[<p>how you did implement your view?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darren</title>
		<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/comment-page-1/#comment-62164</link>
		<dc:creator>Darren</dc:creator>
		<pubDate>Sat, 25 Oct 2008 23:50:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=20#comment-62164</guid>
		<description>That search method in your model could be quite a bit simpler than that I believe. mySQL is pretty smart so the downcase isn&#039;t needed. You also don&#039;t need to split up a string and check against each word.

  def self.search(query)
    unless query.to_s.strip.empty?
      find(:all, :conditions =&gt; [&#039;title like ? or description like ?&#039;, &quot;%#{query}%&quot;, &quot;%#{query}%&quot;], :order =&gt; &#039;created_at desc&#039;, :limit=&gt;25)
    end
  end
</description>
		<content:encoded><![CDATA[<p>That search method in your model could be quite a bit simpler than that I believe. mySQL is pretty smart so the downcase isn&#8217;t needed. You also don&#8217;t need to split up a string and check against each word.</p>
<p>  def self.search(query)<br />
    unless query.to_s.strip.empty?<br />
      find(:all, :conditions =&gt; ['title like ? or description like ?', "%#{query}%", "%#{query}%"], :order =&gt; &#8216;created_at desc&#8217;, :limit=&gt;25)<br />
    end<br />
  end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zaf</title>
		<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/comment-page-1/#comment-60752</link>
		<dc:creator>Zaf</dc:creator>
		<pubDate>Thu, 25 Sep 2008 07:42:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=20#comment-60752</guid>
		<description>undefined local variable or method `query&#039; for #:0xb75a1a4c&gt;

this pops up.. how can i fix it?</description>
		<content:encoded><![CDATA[<p>undefined local variable or method `query&#8217; for #:0xb75a1a4c&gt;</p>
<p>this pops up.. how can i fix it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose</title>
		<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/comment-page-1/#comment-40256</link>
		<dc:creator>Jose</dc:creator>
		<pubDate>Wed, 20 Feb 2008 13:08:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=20#comment-40256</guid>
		<description>Jao, you can use this code for pagination: http://snippets.dzone.com/posts/show/389

In this example you could write:

def songs
   @query = @params[&quot;query&quot;]
   @song_pages, @songs = paginate_collection(Song.search(@query), :per_page =&gt; 10)
end</description>
		<content:encoded><![CDATA[<p>Jao, you can use this code for pagination: <a href="http://snippets.dzone.com/posts/show/389" rel="nofollow">http://snippets.dzone.com/posts/show/389</a></p>
<p>In this example you could write:</p>
<p>def songs<br />
   @query = @params["query"]<br />
   @song_pages, @songs = paginate_collection(Song.search(@query), :per_page =&gt; 10)<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rory</title>
		<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/comment-page-1/#comment-21988</link>
		<dc:creator>Rory</dc:creator>
		<pubDate>Fri, 14 Sep 2007 01:29:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=20#comment-21988</guid>
		<description>The built-in Rails bind variable facility will handle that, P.</description>
		<content:encoded><![CDATA[<p>The built-in Rails bind variable facility will handle that, P.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: P</title>
		<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/comment-page-1/#comment-21983</link>
		<dc:creator>P</dc:creator>
		<pubDate>Thu, 13 Sep 2007 22:06:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=20#comment-21983</guid>
		<description>Doesn&#039;t this leave your database open to SQL injection? What&#039;s to stop the user from entering something like &quot;; drop table songs ;&quot; or something like that?</description>
		<content:encoded><![CDATA[<p>Doesn&#8217;t this leave your database open to SQL injection? What&#8217;s to stop the user from entering something like &#8220;; drop table songs ;&#8221; or something like that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim K.</title>
		<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/comment-page-1/#comment-7151</link>
		<dc:creator>Jim K.</dc:creator>
		<pubDate>Thu, 12 Apr 2007 14:57:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=20#comment-7151</guid>
		<description>Great tutorial. Thanks a bunch.</description>
		<content:encoded><![CDATA[<p>Great tutorial. Thanks a bunch.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/comment-page-1/#comment-3569</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Tue, 20 Feb 2007 20:32:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=20#comment-3569</guid>
		<description>Good stuff Rory. Thanks for the tip!</description>
		<content:encoded><![CDATA[<p>Good stuff Rory. Thanks for the tip!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jao</title>
		<link>http://www.roryhansen.ca/2005/07/07/implementing-search-in-ruby-on-rails/comment-page-1/#comment-103</link>
		<dc:creator>jao</dc:creator>
		<pubDate>Mon, 27 Mar 2006 19:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=20#comment-103</guid>
		<description>first i must apologize for my lack of experience.
What i need to know is how would you use pagination within this method?

thank you.

jao</description>
		<content:encoded><![CDATA[<p>first i must apologize for my lack of experience.<br />
What i need to know is how would you use pagination within this method?</p>
<p>thank you.</p>
<p>jao</p>
]]></content:encoded>
	</item>
</channel>
</rss>
