<?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: Targetting associated tables in an ActiveRecord conditions hash</title>
	<atom:link href="http://omgsean.com/2009/02/targetting-associated-tables-in-an-activerecord-conditions-hash/feed/" rel="self" type="application/rss+xml" />
	<link>http://omgsean.com/2009/02/targetting-associated-tables-in-an-activerecord-conditions-hash/</link>
	<description>It's a Site on the Internet</description>
	<lastBuildDate>Wed, 23 Nov 2011 18:40:30 -0800</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: Sean</title>
		<link>http://omgsean.com/2009/02/targetting-associated-tables-in-an-activerecord-conditions-hash/comment-page-1/#comment-89</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Thu, 30 Apr 2009 12:34:37 +0000</pubDate>
		<guid isPermaLink="false">http://omgsean.com/?p=3#comment-89</guid>
		<description>That&#039;s entirely possible.  Try taking a look at the SQL that&#039;s produced and see if it makes sense.  You may need to use :joins instead of :include, I&#039;ve never used this functionality on a polymorphic association.</description>
		<content:encoded><![CDATA[<p>That&#8217;s entirely possible.  Try taking a look at the SQL that&#8217;s produced and see if it makes sense.  You may need to use :joins instead of :include, I&#8217;ve never used this functionality on a polymorphic association.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://omgsean.com/2009/02/targetting-associated-tables-in-an-activerecord-conditions-hash/comment-page-1/#comment-87</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Thu, 30 Apr 2009 04:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://omgsean.com/?p=3#comment-87</guid>
		<description>The relationship I&#039;m using is polymorphic - I wonder if there are issues with that . . .</description>
		<content:encoded><![CDATA[<p>The relationship I&#8217;m using is polymorphic &#8211; I wonder if there are issues with that . . .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://omgsean.com/2009/02/targetting-associated-tables-in-an-activerecord-conditions-hash/comment-page-1/#comment-86</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Thu, 30 Apr 2009 04:15:23 +0000</pubDate>
		<guid isPermaLink="false">http://omgsean.com/?p=3#comment-86</guid>
		<description>I&#039;m having the same trouble:  Active Record is saying &quot;unknown column&quot;. If I build it the literal way with a string like:  conditions =&gt; &#039;entities.name . . .&#039;  then it works just fine, so I don&#039;t think it&#039;s a problem with the model set-up. Any thoughts appreciated</description>
		<content:encoded><![CDATA[<p>I&#8217;m having the same trouble:  Active Record is saying &#8220;unknown column&#8221;. If I build it the literal way with a string like:  conditions =&gt; &#8216;entities.name . . .&#8217;  then it works just fine, so I don&#8217;t think it&#8217;s a problem with the model set-up. Any thoughts appreciated</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://omgsean.com/2009/02/targetting-associated-tables-in-an-activerecord-conditions-hash/comment-page-1/#comment-76</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Thu, 23 Apr 2009 18:15:36 +0000</pubDate>
		<guid isPermaLink="false">http://omgsean.com/?p=3#comment-76</guid>
		<description>Hi Federico,

Try :entity =&gt; {:name =&gt; &quot;AFY&quot;} instead of :entities =&gt; {:name =&gt; &quot;AFY&quot;}.  Failing that, make sure your relationships are set up properly at the model level.</description>
		<content:encoded><![CDATA[<p>Hi Federico,</p>
<p>Try :entity => {:name => &#8220;AFY&#8221;} instead of :entities => {:name => &#8220;AFY&#8221;}.  Failing that, make sure your relationships are set up properly at the model level.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Federico</title>
		<link>http://omgsean.com/2009/02/targetting-associated-tables-in-an-activerecord-conditions-hash/comment-page-1/#comment-75</link>
		<dc:creator>Federico</dc:creator>
		<pubDate>Thu, 23 Apr 2009 17:35:34 +0000</pubDate>
		<guid isPermaLink="false">http://omgsean.com/?p=3#comment-75</guid>
		<description>I have been trying to use hash as a conditions but it doesn&#039;t seem to work. Here is my code.
documents = Document.find(:all, :include =&gt; :entity, :conditions =&gt; {:entities =&gt; {:name =&gt; &quot;AFY&quot;}})
I get the following error. &quot;ActiveRecord::StatementInvalid: Mysql::Error: Unknown column &#039;entity.name&#039; in &#039;where clause&#039;: SELECT * FROM `documents` WHERE (`entity`.`name` = &#039;AFY&#039;)&quot;

What am i doing wrong? Also would it work if i have the include nested a level deeper? like so: 
documents = Document.find(:all, :include =&gt; {:entity =&gt; :accesses}, :conditions =&gt; {:entities =&gt; {:accesses =&gt; {:user_id =&gt; user.id}}})

I&#039;am on rails 2.3.2, thanks.</description>
		<content:encoded><![CDATA[<p>I have been trying to use hash as a conditions but it doesn&#8217;t seem to work. Here is my code.<br />
documents = Document.find(:all, :include =&gt; :entity, :conditions =&gt; {:entities =&gt; {:name =&gt; &#8220;AFY&#8221;}})<br />
I get the following error. &#8220;ActiveRecord::StatementInvalid: Mysql::Error: Unknown column &#8216;entity.name&#8217; in &#8216;where clause&#8217;: SELECT * FROM `documents` WHERE (`entity`.`name` = &#8216;AFY&#8217;)&#8221;</p>
<p>What am i doing wrong? Also would it work if i have the include nested a level deeper? like so:<br />
documents = Document.find(:all, :include =&gt; {:entity =&gt; :accesses}, :conditions =&gt; {:entities =&gt; {:accesses =&gt; {:user_id =&gt; user.id}}})</p>
<p>I&#8217;am on rails 2.3.2, thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lolcatz</title>
		<link>http://omgsean.com/2009/02/targetting-associated-tables-in-an-activerecord-conditions-hash/comment-page-1/#comment-4</link>
		<dc:creator>lolcatz</dc:creator>
		<pubDate>Thu, 05 Feb 2009 22:21:08 +0000</pubDate>
		<guid isPermaLink="false">http://omgsean.com/?p=3#comment-4</guid>
		<description>You should check out Ambition. It gives you more rubyish syntax.</description>
		<content:encoded><![CDATA[<p>You should check out Ambition. It gives you more rubyish syntax.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Soeder</title>
		<link>http://omgsean.com/2009/02/targetting-associated-tables-in-an-activerecord-conditions-hash/comment-page-1/#comment-3</link>
		<dc:creator>Jonathan Soeder</dc:creator>
		<pubDate>Thu, 05 Feb 2009 20:01:49 +0000</pubDate>
		<guid isPermaLink="false">http://omgsean.com/?p=3#comment-3</guid>
		<description>Ever try Squirrel, from ThoughtBot?

http://thoughtbot.com/projects/squirrel

This allows you to pass a block to ActiveRecord&#039;s find method

and do some really pretty queries in ruby.

js</description>
		<content:encoded><![CDATA[<p>Ever try Squirrel, from ThoughtBot?</p>
<p><a href="http://thoughtbot.com/projects/squirrel" rel="nofollow">http://thoughtbot.com/projects/squirrel</a></p>
<p>This allows you to pass a block to ActiveRecord&#8217;s find method</p>
<p>and do some really pretty queries in ruby.</p>
<p>js</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nachokb</title>
		<link>http://omgsean.com/2009/02/targetting-associated-tables-in-an-activerecord-conditions-hash/comment-page-1/#comment-2</link>
		<dc:creator>nachokb</dc:creator>
		<pubDate>Thu, 05 Feb 2009 19:42:25 +0000</pubDate>
		<guid isPermaLink="false">http://omgsean.com/?p=3#comment-2</guid>
		<description>Have a look at Searchlogic [1], it takes hash conditions to a new level...

-- nachokb

[1] http://github.com/binarylogic/searchlogic</description>
		<content:encoded><![CDATA[<p>Have a look at Searchlogic [1], it takes hash conditions to a new level&#8230;</p>
<p>&#8211; nachokb</p>
<p>[1] <a href="http://github.com/binarylogic/searchlogic" rel="nofollow">http://github.com/binarylogic/searchlogic</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

