<?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: Querying Multiple Tables With ActiveRecord</title>
	<atom:link href="http://thinkinginrails.com/2010/04/querying-multiple-tables-with-activerecord/feed/" rel="self" type="application/rss+xml" />
	<link>http://thinkinginrails.com/2010/04/querying-multiple-tables-with-activerecord/</link>
	<description>A Perl Programmer&#039;s Exploration of The World of Ruby on Rails</description>
	<lastBuildDate>Thu, 08 Nov 2012 20:35:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Stephan Wehner</title>
		<link>http://thinkinginrails.com/2010/04/querying-multiple-tables-with-activerecord/comment-page-1/#comment-889</link>
		<dc:creator>Stephan Wehner</dc:creator>
		<pubDate>Sun, 28 Nov 2010 06:52:25 +0000</pubDate>
		<guid isPermaLink="false">http://thinkinginrails.com/?p=200#comment-889</guid>
		<description><![CDATA[Try naming your class after the table names. 

%w( Archive201001 Archive201002 Archive201003 ).each do &#124;tablename&#124;
eval &lt;&lt;-END_EVAL
  class #{tablename} &lt; ActiveRecord::Base
  end
END_EVAL
end

Now

Archive201001.count
Archive201002.count
Archive201003.count

should all work. Looks a bit silly.

Other way,

%w( Archive201001 Archive201002 Archive201003 ).each do &#124;tablename&#124;
   Test.set_tablename(tablename)
   res = Test.find( :all, :conditions =&gt; &quot;name like &#039;test%&#039;&quot; );
   puts &quot;Total results from #{tablename}: #{res.size.to_s}&quot;
end

(Haven&#039;t run the code / might have some syntax error still.

Stephan]]></description>
		<content:encoded><![CDATA[<p>Try naming your class after the table names. </p>
<p>%w( Archive201001 Archive201002 Archive201003 ).each do |tablename|<br />
eval &lt;&lt;-END_EVAL<br />
  class #{tablename} &lt; ActiveRecord::Base<br />
  end<br />
END_EVAL<br />
end</p>
<p>Now</p>
<p>Archive201001.count<br />
Archive201002.count<br />
Archive201003.count</p>
<p>should all work. Looks a bit silly.</p>
<p>Other way,</p>
<p>%w( Archive201001 Archive201002 Archive201003 ).each do |tablename|<br />
   Test.set_tablename(tablename)<br />
   res = Test.find( :all, :conditions =&gt; &quot;name like &#039;test%&#039;&quot; );<br />
   puts &quot;Total results from #{tablename}: #{res.size.to_s}&quot;<br />
end</p>
<p>(Haven&#039;t run the code / might have some syntax error still.</p>
<p>Stephan</p>
]]></content:encoded>
	</item>
</channel>
</rss>
