<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dr Nic &#187; Trick</title>
	<atom:link href="http://drnicwilliams.com/category/trick/feed/" rel="self" type="application/rss+xml" />
	<link>http://drnicwilliams.com</link>
	<description>Ruby makes Rails, Javascript makes Ajax, Dr Nic makes Magic</description>
	<lastBuildDate>Mon, 15 Mar 2010 20:51:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Customized Google Forms</title>
		<link>http://drnicwilliams.com/2010/02/25/customized-google-forms/</link>
		<comments>http://drnicwilliams.com/2010/02/25/customized-google-forms/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 11:30:24 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Mocra]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Trick]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=688</guid>
		<description><![CDATA[
Google Forms are a great, free way to collect information from anyone, stored directly into a Google Spreadsheet, and then have Google notify you each time a form is submitted (optionally). The downside is that you can only use one of their pre-packaged themes. You can&#8217;t have your company logo and corporate &#8220;look&#8221;.
Pooey to Google, [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2009/03/30/closing-in-on-the-dream-one-click-to-deploy-rails-apps/' rel='bookmark' title='Permanent Link: Closing in on The Dream: &#8220;one-click-to-deploy Rails apps&#8221;'>Closing in on The Dream: &#8220;one-click-to-deploy Rails apps&#8221;</a> <small> Got a simple app you want to build? Allocate...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://img.skitch.com/20100225-rm11rdpj6qib6ukbwdi87ewd76.preview.jpg" alt="Google Form Customized" style="float: right; width: 200px"/></p>
<p>Google Forms are a great, free way to collect information from anyone, stored directly into a Google Spreadsheet, and then have Google notify you each time a form is submitted (optionally). The downside is that you can only use one of their pre-packaged themes. You can&#8217;t have your company logo and corporate &#8220;look&#8221;.</p>
<p>Pooey to Google, we say. So we wrote <a href="http://github.com/mocra/custom_google_forms">custom_google_forms</a>.</p>
<p>Want to truly customized Google Forms? Fork this repository, customize the CSS, DOM and images, and deploy to Heroku. You can then host/customize any number of Google Forms.</p>
<p>For example, here is an original <a href="http://spreadsheets.google.com/a/mocra.com/viewform?formkey=dFo0LXQyYmlEV2dXcVJ6WjRweW9vRnc6MA">bare Google Form</a> and here is a <a href="http://forms.mocra.com/railsdev">fully customized version</a>, including form validation and thank you page.</p>
<p>It&#8217;s fully a dynamic, thin layer on top of Google Forms. If you change your Google Form, your custom form application automatically changes.</p>
<h2 id="how_to_use_google_forms">How to use Google Forms?</h2>
<p>Perhaps read <a href="http://docs.google.com/support/bin/answer.py?hl=en&amp;answer=87809">this docco</a>? Essentially if you can access Google Spreadsheets, you can create a Google Form (which automatically creates and updates a Google Spreadsheet based on the fields and form submissions).</p>
<h2 id="fork_and_customize">Fork and Customize</h2>
<p>It&#8217;s really simple to play with and customize Google Forms. Clone the <a href="http://github.com/mocra/custom_google_forms">GitHub project</a> and fire up the Rails server:</p>
<pre><code>gem install github
cd ~/Sites
gh clone mocra/custom-google-forms yourdomain-google-forms
cd yourdomain-google-forms
script/server
</code></pre>
<p>Go to <a href="http://localhost:3000/google_forms/new">http://localhost:3000/google_forms/new</a> and add a Google Form:</p>
<p><img src="http://img.skitch.com/20100225-msfc5a8gk5rnm5pm7qdy9fd6x6.jpg" alt="My Google Forms - New" style="width: 100%"/></p>
<p>The &#8220;Slug&#8221; is the URL path people will follow. That is, a slug &#8220;railsdev&#8221; maps to <a href="http://forms.mocra.com/railsdev">http://forms.mocra.com/railsdev</a>.</p>
<p>The &#8220;Form Key&#8221; field takes either the <a href="http://spreadsheets.google.com/a/mocra.com/viewform?hl=en&amp;formkey=dFo0LXQyYmlEV2dXcVJ6WjRweW9vRnc6MA">Form URL</a> or just the formkey parameter (e.g. dFo0LXQyYmlEV2dXcVJ6WjRweW9vRnc6MA) from when you view the live form.</p>
<p>Press &#8220;Create&#8221; and follow the slug url to view your Google Form through your own customized style.</p>
<p>Well, initially you&#8217;ll see the Mocra style. Let&#8217;s fix that.</p>
<h1 id="default_theme">Default Theme</h1>
<p>First, fork the github repository so that you can push your style changes to your own repo.</p>
<pre><code>gh fork
mate public/stylesheets/style.css
</code></pre>
<p>Now, edit <a href="http://github.com/mocra/custom_google_forms/blob/master/public/stylesheets/style.css">public/stylesheets/style.css</a> to your tastes.</p>
<p>Please don&#8217;t reuse our style. Aside from you looking a bit silly having the :mocra logo at the top, it would be weird if your forms looked like our forms. I guess you might as well have used the default Google Form themes?</p>
<h1 id="heroku_deployment">Heroku Deployment</h1>
<p>Let&#8217;s not get fancy, let&#8217;s just deploy your fork to Heroku. It&#8217;s free. It&#8217;s simple. You&#8217;ll be done in two minutes.</p>
<p>To get your copy of the application deployed to <a href="http://heroku.com">heroku</a>:</p>
<pre><code>gem install heroku
heroku create yourdomain-google-forms
git push heroku master
heroku rake db:migrate
</code></pre>
<p>Two optional environment variables:</p>
<pre><code>heroku config:add GOOGLE_ANALYTICS='YOURCODE'
</code></pre>
<p>If specified, Google Analytics will be included on all pages (including the custom Google Forms page).</p>
<pre><code>heroku config:add EXPECTED_DOMAIN='some.yourdomain.com'
</code></pre>
<p>If specified, &#8216;yourdomain-google-forms.heroku.com/someform&#8217; automatically redirects to &#8216;some.domain.com/someform&#8217;. </p>
<p>For example, for http://forms.mocra.com we used:</p>
<pre><code>heroku config:add GOOGLE_ANALYTICS='UA-5370510-4'
heroku config:add EXPECTED_DOMAIN='forms.mocra.com'
</code></pre>
<h1 id="getting_started">Getting Started</h1>
<p>Once deployed, go to the /google_forms/new URL and add your first form. Once it is validated and added, you can start using it using the links shown.</p>
<h1 id="summary">Summary</h1>
<p>Yay for free, customized Google Forms! Yay for free Heroku hosting!</p>
<p>Bonus: you can configure your Google Forms/Spreadsheet to notify you when new forms are submitted. That&#8217;s handy.</p>
<p>Thanks to Odin Dutton, our resident designer at Mocra, who did a great job applying our new theme to the Google Forms DOM structure. It&#8217;s wonderful having him on the team!</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2009/03/30/closing-in-on-the-dream-one-click-to-deploy-rails-apps/' rel='bookmark' title='Permanent Link: Closing in on The Dream: &#8220;one-click-to-deploy Rails apps&#8221;'>Closing in on The Dream: &#8220;one-click-to-deploy Rails apps&#8221;</a> <small> Got a simple app you want to build? Allocate...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2010/02/25/customized-google-forms/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>hash bang cucumber</title>
		<link>http://drnicwilliams.com/2009/10/07/hash-bang-cucumber/</link>
		<comments>http://drnicwilliams.com/2009/10/07/hash-bang-cucumber/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 04:37:02 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Trick]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=594</guid>
		<description><![CDATA[I don&#8217;t know if this is a good idea or not, but often I just wish I could copy and paste a cucumber feature file into the command line and have it just run the frigging scenarios without having to prefix it with &#8220;cucumber&#8221;.

Perhaps I&#8217;m a bit delirious but I think it would be fun [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2009/04/15/cucumber-building-a-better-world-object/' rel='bookmark' title='Permanent Link: Cucumber: building a better World (object)'>Cucumber: building a better World (object)</a> <small>How to write helper libraries for your Cucumber step definitions...</small></li><li><a href='http://drnicwilliams.com/2009/03/26/testing-outbound-emails-with-cucumber/' rel='bookmark' title='Permanent Link: Testing outbound emails with Cucumber'>Testing outbound emails with Cucumber</a> <small> My testimonial for Cucumber still stands even in 2009....</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know if this is a good idea or not, but often I just wish I could copy and paste a cucumber feature file into the command line and have it just run the frigging scenarios without having to prefix it with &#8220;cucumber&#8221;.</p>
<p><img src="http://img.skitch.com/20091007-fpa5dmbe4npyiyh3y61y3g1ahj.jpg" alt="running scenarios directly from command line" style="width: 100%" /></p>
<p>Perhaps I&#8217;m a bit delirious but I think it would be fun to paste <code>features/112_users_crud.feature</code> into the console and it would run the scenarios:</p>
<pre>$ features/users_crud.feature</pre>
<p>instead of having to always do the extra key strokes:</p>
<pre>$ cucumber features/users_crud.feature</pre>
<h3>Solution?</h3>
<p>Two steps:</p>
<ol>
<li>At the very top of each feature file add: <code>#!/usr/bin/env cucumber</code></li>
<li>Run <code>chmod +x features/*.feature</code>
</ol>
<p>Shazam!</p>
<h3>Hash bang me up!</h3>
<p>To apply this to all your feature files, jump into <code>script/console</code> or <code>irb</code> and run the following code within your project:</p>
<pre>
Dir["**/*.feature"].each do |feature|
  contents = File.read(feature)
  File.open(feature, "w") do |f|
    f << "#!/usr/bin/env cucumber\n\n"
    f << contents
  end
  `chmod +x "#{feature}"`
end
</pre>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2009/04/15/cucumber-building-a-better-world-object/' rel='bookmark' title='Permanent Link: Cucumber: building a better World (object)'>Cucumber: building a better World (object)</a> <small>How to write helper libraries for your Cucumber step definitions...</small></li><li><a href='http://drnicwilliams.com/2009/03/26/testing-outbound-emails-with-cucumber/' rel='bookmark' title='Permanent Link: Testing outbound emails with Cucumber'>Testing outbound emails with Cucumber</a> <small> My testimonial for Cucumber still stands even in 2009....</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2009/10/07/hash-bang-cucumber/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Get ready for the TextMate &#8220;Trundle to Rails 2.0 Bundle&#8221;</title>
		<link>http://drnicwilliams.com/2008/01/31/get-ready-for-the-textmate-trundle-to-rails-20-bundle/</link>
		<comments>http://drnicwilliams.com/2008/01/31/get-ready-for-the-textmate-trundle-to-rails-20-bundle/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 03:11:59 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[Trick]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2008/01/31/get-ready-for-the-textmate-trundle-to-rails-20-bundle/</guid>
		<description><![CDATA[

Have you noticed lately that the Rails TextMate git pull origin two_point_oohbundle (also installed with e &#8211; the Text Editor for Windows) isn&#8217;t quite as helpful as it once was &#8211; guiding and amplifying your rails app development.

Your resourceful/restful rails apps are now filled with named routes, but none of the helpers (link_to, redirect_to, etc) [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' rel='bookmark' title='Permanent Link: Using CoffeeScript in Rails and even on Heroku'>Using CoffeeScript in Rails and even on Heroku</a> <small>I&#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for...</small></li><li><a href='http://drnicwilliams.com/2009/11/03/first-look-at-rails-3-0-pre/' rel='bookmark' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li><li><a href='http://drnicwilliams.com/2009/10/07/rails-themes-can-remember-things/' rel='bookmark' title='Permanent Link: Rails themes can remember things'>Rails themes can remember things</a> <small>I was getting annoyed at having to remember all the...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<div>
<a style="float: right; padding: 5px" href='http://drnicwilliams.com/2008/01/31/get-ready-for-the-textmate-trundle-to-rails-20-bundle/attachment/257/' rel='attachment wp-att-257' title='logo_bundle.png'><img src='http://drnicwilliams.com/wp-content/uploads/2008/01/logo_bundle.png' alt='logo_bundle.png' /></a></p>
<p>Have you noticed lately that the Rails <a href="http://macromates.com">TextMate</a> git pull origin two_point_oohbundle (also installed with <a href="http://www.e-texteditor.com/">e &#8211; the Text Editor</a> for Windows) isn&#8217;t quite as helpful as it once was &#8211; guiding and amplifying your rails app development.
</div>
<p>Your resourceful/restful rails apps are now filled with named routes, but none of the helpers (link_to, redirect_to, etc) use them. The default view template was still <code>rhtml</code> for a long time (latest svn trunk fixes this to be <code>html.erb</code>, though Marc Jeanson is having a crack at supporting both through a per-project config file). </p>
<p>Or perhaps you were hoping for some snippets for new features of Rails 2.0: assert_difference (asd), assert_select (ass), respond_to (rst). </p>
<p><strong>Or just maybe, you&#8217;ve been updating your local bundle to Rails 2.0 already?</strong> Please say yes, please say yes. If you are saying &#8220;yes&#8221;, read at the bottom for how/where to send me the patches. If you are saying &#8220;no&#8221;, read at the bottom for how/where to start creating patches and sending them to me.</p>
<h3>Firstly, DHH didn&#8217;t write the Rails bundle</h3>
<p>I didn&#8217;t know this &#8211; I just assumed the guy who created Rails and helped promote TextMate also created the Ruby on Rails TextMate bundle. Instead if was WWF&#8217;s &#8220;The Rock&#8221; himself <a href="http://blog.inquirylabs.com/category/software-engineering/">Duane Johnson</a> (figurines sold separately, and may look different to the real Duane Johnson who writes Rails code instead of prancing around in his underpants with other adult males in confined spaces).</p>
<p>The TextMate SVN logs say that it the bundle was first committed in Jan 2005. Its now Jan 2008. That&#8217;s three years of maintaining a suite of code that thousands of people take for granted every day writing Rails code. What a champion.</p>
<p>Like the Australian Cricket team&#8217;s wicketkeeper, <a href="http://en.wikipedia.org/wiki/Adam_Gilchrist">Adam Gilchrist</a>, he&#8217;s also retiring at the top of his game.</p>
<h3>New Maintainer&#8230; me</h3>
<p>Instead of maintaining my own projects, I&#8217;ve decided to maintain this one. I love the TextMate bundles. Before I had a Mac, I <a href="http://drnicwilliams.com/category/radrails/">ported them across to RadRails</a> and many RadRailers entered a golden era of snippet happiness.</p>
<p>My bundle-fu may not be the equivalent of Bruce Lee, but I&#8217;m keen to see my favourite Rails tool live on strong.</p>
<h3>Bleeding edge bundle</h3>
<p>Whilst the TextMate SVN administrators process the maintainer change request (Allan is on holidays somewhere and he took the house keys with him), you might think all is lost!</p>
<p>Never. </p>
<p>The straight-off-the-cow bleeding edge Rails bundle can be accessed via Git. Specifically the branch <a href="http://github.com/drnic/ruby-on-rails-tmbundle/tree/two_point_ooh">two_point_ooh</a>.</p>
<p>So, let&#8217;s all do away with our pre-existing Rails bundle and live on the edge.</p>
<pre>
cd ~/"Library/Application Support/TextMate/Bundles/"
mv "Ruby on Rails.tmbundle" "RoR.tmbundle.orig"
git clone git://github.com/drnic/ruby-on-rails-tmbundle.git "Ruby on Rails.tmbundle"
cd "Ruby on Rails.tmbundle"
git checkout --track -b two_point_ooh origin/two_point_ooh
git pull
</pre>
<p>Now, back in TextMate, go to menu &#8220;Bundles&#8221; > &#8220;Bundle Editor&#8221; > &#8220;Reload Bundles&#8221;.</p>
<p>You, my friend, are sitting pretty.</p>
<h3>Upgrading to when newer blood is on the bleeding edge</h3>
<p>Coming back for more?</p>
<pre>
cd ~/"Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle"
git checkout two_point_ooh  # optional; only if you changed to another branch etc
git pull
</pre>
<p>Now, back in TextMate, go to menu &#8220;Bundles&#8221; > &#8220;Bundle Editor&#8221; > &#8220;Reload Bundles&#8221;.</p>
<p>Bathe yourself in glory. Splash it all over yourself.</p>
<h3>Submitting patches</h3>
<p>If you go into TextMate, launch the Bundle Editor (Cmd+Alt+Ctrl+B) and change something in the Ruby on Rails bundle, then files will added/changed within your local git clone. </p>
<p>What I mean is, you can very simply submit patches now. [When I say "simply", I mean, "I think this is the best approach but I could be completely wrong here..."] Git is so cool that I don&#8217;t know what its doing most of the time; but let&#8217;s hang in there as a team.</p>
<pre>
cd ~/"Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle"
git add .   # to add any new files/snippets/commands you created; TextMate uses one file per snippet
git commit -a -m "Useful message about this patch goes here"
git diff -p HEAD^ HEAD
</pre>
<p>[Theoretically] this creates a patch based on your most recent commit. So you can easily create patches for changes even if your repository and the remote/central/bleeding edge repository look different.</p>
<p>If your patch was created over several commits, then replace HEAD^ with HEAD~4, if there were 4 commits.</p>
<p>I think. God I could be wrong about this though.</p>
<p>Just try your best and if it works, let me know and I&#8217;ll remove all this &#8220;I don&#8217;t know what I&#8217;m talking about&#8221; text and future readers will think I know everything. Web 2.0 rocks.</p>
<h3>Send patches to&#8230;</h3>
<p>Me <a href="mailto:drnicwilliams@gmail.com">drnicwilliams@gmail.com</a> <strong>[update] </strong>or via the <strong>new</strong> <a href="http://groups.google.com/group/rails-textmate">Google Group</a>.</p>
<p><strong>Update:</strong> Note there is a new Google Group (<a href="http://groups.google.com/group/rubyonrails-textmate">rails-textmate</a>) created in Feb 2009 due to Spam and loss of admin control on original group.</p>
<p>Want to fork the git repo? Use a free account at <a href="http://gitorious.org/">Gitorious</a> or <a href="http://github.com">GitHub</a>.</p>
<table style="background-color: #fff; padding: 5px;" cellspacing=0>
<tr>
<td>
  <img src="http://groups.google.com/groups/img/3nb/groups_bar.gif" height=26 width=132 alt="Google Groups">
  </td>
</tr>
<tr>
<td style="padding-left: 5px;font-size: 125%">
  <b>Ruby on Rails: TextMate</b>
  </td>
</tr>
<tr>
<td style="padding-left: 5px">
  <a href="http://groups.google.com/group/rails-textmate">Visit this group</a>
  </td>
</tr>
</table>
<h3>Trundle to Rails 2.0 Bundle</h3>
<p>Arguably, we just keep patching the bundle forever and bleeding edges will continue to live happily within the blood and muck of said existence.</p>
<p>But, lots of other people want nicely zipped up bundles. No doubt &#8220;e &#8211; the Text Editor&#8221; will want a &#8220;released&#8221; version so they can clean it of all the ugly things they can&#8217;t yet replicate like Macros. And eventually I&#8217;ll push it all down to the SVN repo and it will be released with future TextMate upgrades.</p>
<p>So, there will be a &#8220;Rails 2.0 compatible&#8221; grand opening one day soon. Probably before 14th of March 2008, when I&#8217;m giving a &#8220;What&#8217;s new in Rails 2.0?&#8221; talk at QCON London. Showing off the new bundle will be sweet. </p>
<p>That gives us 6 wks to refactor this bundle to make it a shining example of all that is wonderful in Rails 2.0. Every patch helps.</p>
<p>[Please consider Rails 1.2.6 and before developers when conceiving of patches, and please consult your doctor if pain persists.]</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' rel='bookmark' title='Permanent Link: Using CoffeeScript in Rails and even on Heroku'>Using CoffeeScript in Rails and even on Heroku</a> <small>I&#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for...</small></li><li><a href='http://drnicwilliams.com/2009/11/03/first-look-at-rails-3-0-pre/' rel='bookmark' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li><li><a href='http://drnicwilliams.com/2009/10/07/rails-themes-can-remember-things/' rel='bookmark' title='Permanent Link: Rails themes can remember things'>Rails themes can remember things</a> <small>I was getting annoyed at having to remember all the...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2008/01/31/get-ready-for-the-textmate-trundle-to-rails-20-bundle/feed/</wfw:commentRss>
		<slash:comments>62</slash:comments>
		</item>
		<item>
		<title>Find objects in IRB directly from browser URLs</title>
		<link>http://drnicwilliams.com/2008/01/01/find-objects-in-irb-directly-from-browser-urls/</link>
		<comments>http://drnicwilliams.com/2008/01/01/find-objects-in-irb-directly-from-browser-urls/#comments</comments>
		<pubDate>Tue, 01 Jan 2008 04:59:39 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Trick]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2008/01/01/find-objects-in-irb-directly-from-browser-urls/</guid>
		<description><![CDATA[A long time ago, I tired of going into the irb/console and finding objects/models using the traditional ActiveRecord command Person.find(15) and now I&#8217;m sitting pretty: I can paste in URLs to fetch objects.

# No more of this:
=> Person.find(15)
# instead:
=> people/15

people/15 is something you&#8217;ll copy+paste directly from your browser: http://localhost:3000/people/15
Of course, the url is based on [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2007/08/12/magiccgi/' rel='bookmark' title='Permanent Link: MagicCGI shows OpenID user count'>MagicCGI shows OpenID user count</a> <small> In the last 20 days, 43 people have used...</small></li><li><a href='http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/' rel='bookmark' title='Permanent Link: Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;'>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</a> <small>At this point in time there’s no facility in Rails...</small></li><li><a href='http://drnicwilliams.com/2006/08/22/bts-magic-models-vs-activerecords-efficiency/' rel='bookmark' title='Permanent Link: [BTS] Magic Models vs ActiveRecords &#8211; Efficiency'>[BTS] Magic Models vs ActiveRecords &#8211; Efficiency</a> <small>Dr Nic&#8217;s Magic Models are magical, that goes without saying....</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>A long time ago, I tired of going into the irb/console and finding objects/models using the traditional ActiveRecord command <code>Person.find(15)</code> and now I&#8217;m sitting pretty: I can paste in URLs to fetch objects.</p>
<pre syntax="ruby">
# No more of this:
=> Person.find(15)
# instead:
=> people/15
</pre>
<p><code>people/15</code> is something you&#8217;ll copy+paste directly from your browser: <code>http://localhost:3000/<strong>people/15</strong></code></p>
<p>Of course, the url is based on your routing + controllers, so the assumption here is that your routes/controllers map to your active record models. That is, your app is smothered in RESTful love and cuddles.</p>
<p>Not following this? Here&#8217;s a <a href="http://drnicwilliams.com/wp-content/uploads/2008/01/urls_into_irb.mov">video</a>:</p>
<p><embed src="http://drnicwilliams.com/wp-content/uploads/2008/01/urls_into_irb.mov"  width="651" height="460" autoplay="false" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/"></embed></p>
<h3>How to make this work at home</h3>
<p>Copy and paste the <a href="http://pastie.textmate.org/133717">following</a> into your <a href="http://drnicwilliams.com/2006/10/12/my-irbrc-for-consoleirb/">.irbrc file</a>:</p>
<textarea name="code" class="ruby" cols="60" rows="10">
# In irb, can type:
# people/6 instead of Person.find(6)
# That is, can paste in urls into irb to find objects.
class ModelProxy
  def initialize(klass)
    @klass = klass
  end
  def /(id)
    @klass.find(id)
  end
end

def define_model_find_shortcuts
  model_files = Dir.glob("app/models/**/*.rb")
  model_names = model_files.map { |f| File.basename(f).split('.')[0..-2].join }
  model_names.each do |model_name|
    Object.instance_eval do
      define_method(model_name.pluralize) do |*args|
        ModelProxy.new(model_name.camelize.constantize)
      end
    end
  end
end
</textarea>
<h3>Thanks goes to&#8230;</h3>
<p>The some original code for this comes via <a href="http://www.clarkware.com/cgi/blosxom/2007/09/03#ConsoleFindShortcut">Mike Clark</a>, who had the idea for syntax <code>activity(6)</code>. This was good.</p>
<p>I previously had another idea to support the syntax <code>6.to_activity</code> using the RubyGem <a href="http://drnicutilities.rubyforge.org/to_activerecord/">to_activerecord</a>. I still like the <code>id.to_class_name</code> structure of this and still use it.</p>
<p>But if I have a perfectly nice looking url sitting in front of me, I can now paste the <code>class_name/id</code> part into irb and I&#8217;m off and running.</p>
<p>Happy New Year.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2007/08/12/magiccgi/' rel='bookmark' title='Permanent Link: MagicCGI shows OpenID user count'>MagicCGI shows OpenID user count</a> <small> In the last 20 days, 43 people have used...</small></li><li><a href='http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/' rel='bookmark' title='Permanent Link: Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;'>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</a> <small>At this point in time there’s no facility in Rails...</small></li><li><a href='http://drnicwilliams.com/2006/08/22/bts-magic-models-vs-activerecords-efficiency/' rel='bookmark' title='Permanent Link: [BTS] Magic Models vs ActiveRecords &#8211; Efficiency'>[BTS] Magic Models vs ActiveRecords &#8211; Efficiency</a> <small>Dr Nic&#8217;s Magic Models are magical, that goes without saying....</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2008/01/01/find-objects-in-irb-directly-from-browser-urls/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
<enclosure url="http://drnicwilliams.com/wp-content/uploads/2008/01/urls_into_irb.mov" length="4838856" type="video/quicktime" />
		</item>
		<item>
		<title>Showing off data on a timeline</title>
		<link>http://drnicwilliams.com/2007/10/28/showing-off-data-on-a-timeline/</link>
		<comments>http://drnicwilliams.com/2007/10/28/showing-off-data-on-a-timeline/#comments</comments>
		<pubDate>Sun, 28 Oct 2007 03:41:21 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[JSON]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MagicCGI]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Trick]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/10/28/showing-off-data-on-a-timeline/</guid>
		<description><![CDATA[I&#8217;m still trying to justify my effort writing the MagicCGI code. It let you get an XML or JSON feed for any database, with some basic conditionals, limits etc. The existing demo is for my blog database. 
I think this one is kinda cool &#8211; showing off all your blog posts/articles on a timeline:

Can&#8217;t see [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2007/08/12/magiccgi/' rel='bookmark' title='Permanent Link: MagicCGI shows OpenID user count'>MagicCGI shows OpenID user count</a> <small> In the last 20 days, 43 people have used...</small></li><li><a href='http://drnicwilliams.com/2007/04/16/aliases-to-the-latest-branch-folder-youre-working-on/' rel='bookmark' title='Permanent Link: Aliases to the latest branch folder you&#8217;re working on'>Aliases to the latest branch folder you&#8217;re working on</a> <small>For my Rails and RubyGem projects I&#8217;ll run multiple branches...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m still trying to justify my effort writing the <a href="http://drnicwilliams.com/2007/08/12/magiccgi/">MagicCGI code</a>. It let you get an XML or JSON feed for any database, with some basic conditionals, limits etc. The existing demo is for my blog database. </p>
<p>I think this one is kinda cool &#8211; showing off all your blog posts/articles on a <a href="http://simile.mit.edu/">timeline</a>:</p>
<p><iframe src="http://drnicwilliams.com/wp-content/blog_timeline/current/" width=550 height=750 border=0></iframe></p>
<caption id="cant_see_timeline"><a href="http://drnicwilliams.com/wp-content/blog_timeline/current/">Can&#8217;t see the snazzy timeline above?</a></caption>
<p>To get the timeline working with the schema output from the Magic CGI, I needed to write my own Timeline EventSource. Currently I don&#8217;t do anything fancy with the generated bubbles &#8211; I just use the defaults.</p>
<p>The MagicCGI query gets all wp_posts (Wordpress schema) rows, where &#8220;post_status=publish&#8221; and only returns fields that are relevant (notably ignores the large post_content field holding the blog content):</p>
<p><a href="http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?format=json&#038;table=wp_posts&#038;post_status=publish&#038;field=ID&#038;field=post_title&#038;field=post_date_gmt&#038;field=post_modified_gmt&#038;field=guid&#038;field=comment_count">http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?<br/>format=json&#038;table=wp_posts&#038;post_status=publish&#038;<br/>field=ID&#038;field=post_title&#038;field=post_date_gmt&#038;<br/>field=post_modified_gmt&#038;field=guid&#038;field=comment_count</a></p>
<p>The other cool thing I did here was to deploy it all with Capistrano (an html page + javascript libs). It even deploys/manages a copy of the Timeline trunk onto the server. This is the first time I&#8217;ve deployed a non-Ruby/Rails app using Capistrano, and once I got it set up it becomes much easier to manage than using an FTP app, etc.</p>
<p>How easy? <code>cap1 update</code> (note the dubious use of capistrano 1&#8230; I still&#8230; haven&#8217;t&#8230; converted&#8230; to 2.0&#8230;)</p>
<p>I&#8217;m not confident enough that my solution is sexy enough to outline in detail, so if you&#8217;re interested in deploying Javascript apps etc with Capistrano, just checkout the code (below) and look at the config/deploy.rb script. (note that I&#8217;ve disabled the <a href="http://www.deprec.org/">deprec</a> require statement as it assumes I&#8217;m wanted to run some mongrels etc, but deprec is very handy for setting up ssh and other fun stuff at the start).</p>
<p>So, no details here, just a fun example. </p>
<p>If the Timeline tickles your fancy, their website has lots of tutorials, and/or check out my html/javascript code.</p>
<pre>
svn co http://drnicwilliams.com/svn/blog_timeline/trunk blog_timeline
</pre>
<p>If the MagicCGI tickles your fancy, its also only on svn at the moment, though its docco should be pretty good. I think. </p>
<pre>
svn co http://rubyforge.org/var/svn/magicmodels/magic_cgi/trunk magic_cgi
</pre>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2007/08/12/magiccgi/' rel='bookmark' title='Permanent Link: MagicCGI shows OpenID user count'>MagicCGI shows OpenID user count</a> <small> In the last 20 days, 43 people have used...</small></li><li><a href='http://drnicwilliams.com/2007/04/16/aliases-to-the-latest-branch-folder-youre-working-on/' rel='bookmark' title='Permanent Link: Aliases to the latest branch folder you&#8217;re working on'>Aliases to the latest branch folder you&#8217;re working on</a> <small>For my Rails and RubyGem projects I&#8217;ll run multiple branches...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/10/28/showing-off-data-on-a-timeline/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MagicCGI shows OpenID user count</title>
		<link>http://drnicwilliams.com/2007/08/12/magiccgi/</link>
		<comments>http://drnicwilliams.com/2007/08/12/magiccgi/#comments</comments>
		<pubDate>Sun, 12 Aug 2007 10:51:04 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[JSON]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[OpenID]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Trick]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/08/12/magiccgi/</guid>
		<description><![CDATA[



In the last 20 days, 43 people have used OpenID to leave comments. That&#8217;s very cool.
Corollary: add OpenID login to your blog.
Even cooler &#8211; Dynamic counter
The screen shot comes from the Comments form.
If you look at the comments form in a week, month, year, the counter above have be changed from its original value 43.
No [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2007/10/28/showing-off-data-on-a-timeline/' rel='bookmark' title='Permanent Link: Showing off data on a timeline'>Showing off data on a timeline</a> <small>I&#8217;m still trying to justify my effort writing the MagicCGI...</small></li><li><a href='http://drnicwilliams.com/2007/09/11/myopenid-goes-down-multiple-openids-useful/' rel='bookmark' title='Permanent Link: Why supporting multiple OpenIDs per User is useful for users&#8230;'>Why supporting multiple OpenIDs per User is useful for users&#8230;</a> <small>Web apps/services go down for maintenance (expected or erroneously) all...</small></li><li><a href='http://drnicwilliams.com/2007/09/11/railsrumble-hates-openid/' rel='bookmark' title='Permanent Link: RailsRumble hates OpenID'>RailsRumble hates OpenID</a> <small>There are 146 RailsRumble entrants. %w[rubygems hpricot open-uri].each { |l|...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<div>
<div style="float:right">
<a class="imagelink" href="http://drnicwilliams.com/wp-content/uploads/2007/08/openid_user_count.png" title="OpenID count"><img id="image220" src="http://drnicwilliams.com/wp-content/uploads/2007/08/openid_user_count.png" alt="OpenID count" /></a>
</div>
<p>In the last 20 days, <span id="openid_counter">43</span> people have used OpenID to leave comments. That&#8217;s very cool.</p>
<p><strong>Corollary</strong>: add OpenID login to your blog.</p>
<h2 id="even_cooler_dynamic_counter">Even cooler &#8211; Dynamic counter</h2>
<p>The screen shot comes from the Comments form.</p>
<p>If you look at the comments form in a week, month, year, the counter above have be changed from its original value 43.</p>
<p>No fancy Wordpress plugins (I don&#8217;t <em>do</em> PHP)</p>
<p>No Apache tricks. (I don&#8217;t know any Apache tricks)</p>
</div>
<p>Instead with Javascript/HTML <em>attached</em> to JSON <em>attached</em> to a RubyCGI script <em>attached</em> to my Wordpress database via ActiveRecords and some magic.</p>
<p>I call it <strong>MagicCGI</strong>. I also call it <strong>Frigging Scary</strong>.</p>
<p>Try the following:</p>
<pre>$ curl -v "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?table=wp_openid_identities&amp;action=count&amp;format=json"
&lt; Content-Type: txt/json
&lt;
43
</pre>
<p>Or some XML?</p>
<pre>$ curl -v "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?table=wp_openid_identities&amp;action=count&amp;format=xml"
&lt; Content-Type: txt/xml
&lt;
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;result&gt;
  &lt;count type="integer"&gt;43&lt;/count&gt;
&lt;/result&gt;
</pre>
<h2 id="raw_data">Raw data?</h2>
<pre>$ curl "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?table=wp_posts&amp;field=post_title&amp;limit=5&amp;order=post_title"
[{"attributes": {"post_title": "OpenID count"}},
 {"attributes": {"post_title": "MagicCGI shows OpenID user count"}},
 {"attributes": {"post_title": "map_by_method now works with ActiveRecord associations"}},
 {"attributes": {"post_title": "Feedburner"}},
 {"attributes": {"post_title": "One year on the InterTubes"}}
]
</pre>
<p>Getting kinda scary now, I think.</p>
<h2 id="ooh_just_how_much_magic">Ooh, just how much magic?</h2>
<p>Want a list of available tables to play with?</p>
<pre>$ curl "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?meta=tables"
[{table_name: 'wp_users'},...]
</pre>
<ul>
<li>add <code>&amp;format=xml</code> to XML output; JSON is default</li>
<li>add <code>&amp;meta=columns</code> to include the column schema definitions</li>
<li>add <code>&amp;table_name=wp_posts</code> for each table you want (instead of all the tables)</li>
</ul>
<p>E.g. to see the columns for <code>wp_posts</code> and no other table, in XML:</p>
<pre>$ curl "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?meta=tables&amp;meta=columns&amp;table_name=wp_posts&amp;format=xml"
</pre>
<p>A list of all urls and internal user_ids for users/OpenID users/registered commenters?</p>
<pre>$ curl "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?table=wp_users&amp;field=user_url&amp;field=id"
[{"attributes": {"id": "1", "user_url": "http://drnicwilliams.com"}}, ...
</pre>
<p>So, now we know Dr Nic = user id 1.</p>
<p>Oh oh oh, how about a list of comments for a specific user?</p>
<pre>$ curl "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?table=wp_comments&amp;user_id=1"
...comments by Dr Nic...
or
$ curl "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?table=wp_comments&amp;user_id=1&amp;action=count"
232
</pre>
<p>Dr Nic&#8217;s commented in his own blog 232 times? Out of how many comments?</p>
<pre>$ curl "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?table=wp_comments&amp;action=count"
963
</pre>
<p>Where are the user emails? Where are their passwords?</p>
<p><strong>Hidden!</strong> See below.</p>
<h2 id="callbacks">Callbacks?</h2>
<p>JSON URLs support <code>callback=someCallbackMethod</code> and/or <code>variable=someLocalVariable</code>.</p>
<pre>$ curl "http://drnicwilliams.com/cgi-bin/wp_drnicwilliams.cgi?table=wp_comments&amp;action=count&amp;callback=someMethod"
someMethod(963);
</pre>
<h2 id="what_does_wp_drnicwilliamscgi_look_like">What does <code>wp_drnicwilliams.cgi</code> look like?</h2>
<p>Something a little like this&#8230; </p>
<pre>#!/usr/local/bin/ruby
require 'magic_cgi'         # loads the render magic, model magic, and meta-model magic
include Render

require 'magic_cgi/config/wordpress'  # connect to DB using Wordpress installation (wp-config.php)
MagicCGI::Config::Wordpress.establish_connection "/path/to/drnicwilliams/web/public"

# The following is defaulted for Wordpress connections:
MagicCGI::Config.hidden_tables |= %w[wp_openid_nonces wp_openid_associations wp_usermeta wp_tla_rss_map wp_tla_data]
MagicCGI::Config.hidden_columns['wp_users'] = %w[user_email user_pass user_activation_key]
MagicCGI::Config.hidden_columns['wp_openid_identities'] = %w[hash]
MagicCGI::Config.hidden_columns['wp_comments'] = %w[comment_author_email comment_author_IP]
MagicCGI::Config.hidden_columns['wp_posts'] = %w[post_password]

render do |params|
  data = DbTable.from_params(params)
  data ||= begin
    table_name = params['table'].first || 'wp_users'
    model_name = ActiveRecord::Base.class_name(table_name)
    klass = MagicCGI::MagicModel.create_class(model_name, ActiveRecord::Base)
    klass.find_or_count_by_params(params)
  end
  data
end
</pre>
<h2 id="can_i_write_my_own_cgi_scripts_for_my_own_dbs">Can I write my own CGI scripts for my own DBs?</h2>
<p>Sure. Its a library called MagicCGI.</p>
<h2 id="what_is_magic_cgi">What is MagicCGI?</h2>
<p>Coming soon.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2007/10/28/showing-off-data-on-a-timeline/' rel='bookmark' title='Permanent Link: Showing off data on a timeline'>Showing off data on a timeline</a> <small>I&#8217;m still trying to justify my effort writing the MagicCGI...</small></li><li><a href='http://drnicwilliams.com/2007/09/11/myopenid-goes-down-multiple-openids-useful/' rel='bookmark' title='Permanent Link: Why supporting multiple OpenIDs per User is useful for users&#8230;'>Why supporting multiple OpenIDs per User is useful for users&#8230;</a> <small>Web apps/services go down for maintenance (expected or erroneously) all...</small></li><li><a href='http://drnicwilliams.com/2007/09/11/railsrumble-hates-openid/' rel='bookmark' title='Permanent Link: RailsRumble hates OpenID'>RailsRumble hates OpenID</a> <small>There are 146 RailsRumble entrants. %w[rubygems hpricot open-uri].each { |l|...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/08/12/magiccgi/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>map_by_method now works with ActiveRecord associations</title>
		<link>http://drnicwilliams.com/2007/08/12/map_by_method-now-works-with-activerecord-associations/</link>
		<comments>http://drnicwilliams.com/2007/08/12/map_by_method-now-works-with-activerecord-associations/#comments</comments>
		<pubDate>Sun, 12 Aug 2007 07:31:58 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Meta-Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Trick]]></category>
		<category><![CDATA[map_by_method]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/08/12/map_by_method-now-works-with-activerecord-associations/</guid>
		<description><![CDATA[I was always annoyed that map_by_method was broken for ActiveRecord has_many associations. 6 mths later I finally fixed it.
That&#8217;s the magic of Open Source Software. [/end sarcasm]
So now, the following example works like it should:
$ gem install map_by_method
$ console
&#62; require 'map_by_method'  # stick this in your environment.rb for Rails
&#62; user = User.find_by_name "Dr Nic"
&#62; [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2008/01/01/find-objects-in-irb-directly-from-browser-urls/' rel='bookmark' title='Permanent Link: Find objects in IRB directly from browser URLs'>Find objects in IRB directly from browser URLs</a> <small>A long time ago, I tired of going into the...</small></li><li><a href='http://drnicwilliams.com/2007/09/07/map_by_method-the-final-announcement/' rel='bookmark' title='Permanent Link: map_by_method &#8211; the final announcement'>map_by_method &#8211; the final announcement</a> <small>I don&#8217;t really talk about my projects after I release...</small></li><li><a href='http://drnicwilliams.com/2007/08/12/magiccgi/' rel='bookmark' title='Permanent Link: MagicCGI shows OpenID user count'>MagicCGI shows OpenID user count</a> <small> In the last 20 days, 43 people have used...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I was always annoyed that <a href="http://drnicutilities.rubyforge.org/map_by_method"><code>map_by_method</code></a> was broken for ActiveRecord <code>has_many</code> associations. 6 mths later I finally fixed it.</p>
<p>That&#8217;s the magic of Open Source Software. [/end sarcasm]</p>
<p>So now, the following example works like it should:</p>
<pre>$ gem install map_by_method
$ console
&gt; require 'map_by_method'  # stick this in your environment.rb for Rails
&gt; user = User.find_by_name "Dr Nic"
&gt; user.companies.map_by_name
=&gt; ['Dr Nic Academy', 'Dr Nic Institute of Being Silly']
&gt; user.companies.map_by_id_and_name
=&gt; [[1, 'Dr Nic Academy'], [9, 'Dr Nic Institute of Being Silly']]
</pre>
<h2 id="recap_why_use_map_by_method">Recap: why use <code>map_by_method</code>?</h2>
<p>Try the following example:</p>
<pre>&gt; user.companies.map_by_employees.flatten
=&gt; list of all employees of user
</pre>
<p>Versus:</p>
<pre>&gt; user.companies.map { |company| company.employees}.flatten
or
&gt; user.companies.map(&amp;:employees).flatten
</pre>
<p>Or compare:</p>
<pre>&gt; user.companies.map_by_id_and_name
=&gt; [[1, 'Dr Nic Academy'], [9, 'Dr Nic Institute of Being Silly']]
</pre>
<p>Versus:</p>
<pre>&gt; user.companies.map { |company| [company.id, company.name]}
</pre>
<p>That is, it looks and feels just like ActiveRecord&#8217;s #find method, with its <code>find_by_first_name_and_last_name</code> magic.</p>
<h2 id="summary">Summary</h2>
<p>No <code>{</code>, <code>}</code>, <code>|</code>, <code>&amp;</code>, or <code>:</code> required. Just clean method names.</p>
<h1 id="bonus_other_gem">Bonus other gem</h1>
<p>In the spirit of ActiveRecord hacks, there is <code>to_activerecord</code>:</p>
<pre>$ gem install to_activerecord
$ console
&gt; require 'to_activerecord'  # stick this in your environment.rb for Rails
&gt; [1,2,3].to_user
=&gt; [list of User with id's 1,2,3]
</pre>
<p>To me, this suffix operator reads cleaner than the traditional:</p>
<pre>&gt; User.find([1,2,3])
</pre>
<p>For example, if you want to perform an operation on the list of Users:</p>
<pre>&gt; ids = [1,2,3]
&gt; ids.to_user.map_by_name
=&gt; ['Dr Nic', 'Banjo', 'Nancy']
</pre>
<p>Versus:</p>
<pre>&gt; User.find(ids).map_by_name
</pre>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2008/01/01/find-objects-in-irb-directly-from-browser-urls/' rel='bookmark' title='Permanent Link: Find objects in IRB directly from browser URLs'>Find objects in IRB directly from browser URLs</a> <small>A long time ago, I tired of going into the...</small></li><li><a href='http://drnicwilliams.com/2007/09/07/map_by_method-the-final-announcement/' rel='bookmark' title='Permanent Link: map_by_method &#8211; the final announcement'>map_by_method &#8211; the final announcement</a> <small>I don&#8217;t really talk about my projects after I release...</small></li><li><a href='http://drnicwilliams.com/2007/08/12/magiccgi/' rel='bookmark' title='Permanent Link: MagicCGI shows OpenID user count'>MagicCGI shows OpenID user count</a> <small> In the last 20 days, 43 people have used...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/08/12/map_by_method-now-works-with-activerecord-associations/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Magic Wiggly Lines =&gt; GuessMethod, by Chris Shea</title>
		<link>http://drnicwilliams.com/2007/07/23/magic-wiggly-lines-guessmethod-by-chris-shea/</link>
		<comments>http://drnicwilliams.com/2007/07/23/magic-wiggly-lines-guessmethod-by-chris-shea/#comments</comments>
		<pubDate>Mon, 23 Jul 2007 07:44:02 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Link]]></category>
		<category><![CDATA[Magic Wiggly Lines]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Trick]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/07/23/magic-wiggly-lines-guessmethod-by-chris-shea/</guid>
		<description><![CDATA[If you ever make time to code just for pleasure, then method_missing and const_missing are just begging for abuse.
Chris Shea has come up with GuessMethod &#8211; a very cool hack that now deprecates my concept of Magic Wiggly Lines &#8211; a spell-checker for runtime code.
What&#8217;s it do? Cop a squiz at this genius&#8230;

$ gem install [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2007/05/23/dr-nics-magic-show-at-rejectconf2007/' rel='bookmark' title='Permanent Link: Dr Nic&#8217;s Magic Show at RejectConf2007'>Dr Nic&#8217;s Magic Show at RejectConf2007</a> <small>Update: there is a patch available for edge rails to...</small></li><li><a href='http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/' rel='bookmark' title='Permanent Link: Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;'>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</a> <small>At this point in time there’s no facility in Rails...</small></li><li><a href='http://drnicwilliams.com/2007/04/12/spring-collection-the-modular-magic-models/' rel='bookmark' title='Permanent Link: Spring Collection &#8211; the Modular Magic Models'>Spring Collection &#8211; the Modular Magic Models</a> <small>Dr Nic&#8217;s Magic Models are like cheating on your taxes...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>If you ever make time to code just for pleasure, then <code>method_missing</code> and <code>const_missing</code> are just begging for abuse.</p>
<p><a href="http://ruby.tie-rack.org/">Chris Shea</a> has come up with <a href="http://ruby.tie-rack.org/9/guessmethod-002/">GuessMethod</a> &#8211; a very cool hack that now deprecates my concept of <a href="http://drnicwilliams.com/2007/03/22/meta-magic-in-ruby-presentation/">Magic Wiggly Lines</a> &#8211; <strong>a spell-checker for runtime code.</strong></p>
<p>What&#8217;s it do? Cop a squiz at this genius&#8230;</p>
<pre class="syntax">
$ gem install guessmethod -y
$ irb
> require 'rubygems'
> require 'guessmethod'
> class Object; include GuessMethod; end  # though this could go in the guessmethod.rb file in the gem
> class Product; def name; "Some product"; end; end
> Prodct.nw.nae
<span class="ident">attention</span>: replacing non-existant constant <span class="constant">Prodct</span> with <span class="constant">Product</span> for <span class="constant">Object</span>
<span class="ident">attention</span>: sending <span class="symbol">new</span> instead of <span class="symbol">nw</span> to <span class="constant">Product:Class</span>
<span class="ident">attention</span>: sending <span class="symbol">name</span> instead of <span class="symbol">nae</span> to <span class="constant">#&lt;Product:0x144ff10>:Product</span>
=> "Some product"
</pre>
<p>That&#8217;s going straight into my <a href="http://drnicwilliams.com/2006/10/12/my-irbrc-for-consoleirb/">.irbrc</a> file. My bad spelling, coupled with my British/Australian English, will never slow me down again!</p>
<p>UPDATE: actually, it doesn&#8217;t like being in the .irbrc file for Rails console; so in the config/environments/development.rb files will have to do for the moment.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2007/05/23/dr-nics-magic-show-at-rejectconf2007/' rel='bookmark' title='Permanent Link: Dr Nic&#8217;s Magic Show at RejectConf2007'>Dr Nic&#8217;s Magic Show at RejectConf2007</a> <small>Update: there is a patch available for edge rails to...</small></li><li><a href='http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/' rel='bookmark' title='Permanent Link: Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;'>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</a> <small>At this point in time there’s no facility in Rails...</small></li><li><a href='http://drnicwilliams.com/2007/04/12/spring-collection-the-modular-magic-models/' rel='bookmark' title='Permanent Link: Spring Collection &#8211; the Modular Magic Models'>Spring Collection &#8211; the Modular Magic Models</a> <small>Dr Nic&#8217;s Magic Models are like cheating on your taxes...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/07/23/magic-wiggly-lines-guessmethod-by-chris-shea/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Auto-completer for my blog comments</title>
		<link>http://drnicwilliams.com/2007/06/30/autocompleter-for-blog-comments/</link>
		<comments>http://drnicwilliams.com/2007/06/30/autocompleter-for-blog-comments/#comments</comments>
		<pubDate>Fri, 29 Jun 2007 22:51:23 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Preview]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Trick]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/06/30/autocompleter-for-blog-comments/</guid>
		<description><![CDATA[It took 4 hours to return from the town of Strängnäs to Stockholm via train. Normally, its 40 minutes. The train never turned up. 4 * 60 &#8211; 40 = 200 minutes of non-travel.
Stuck in a train station for 200 minutes I tackled a problem that has irked me for some time.
In my blog comments, [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2008/05/03/github-badge-for-your-blog/' rel='bookmark' title='Permanent Link: GitHub Badge for your Blog with 100% guarantee of more coolness'>GitHub Badge for your Blog with 100% guarantee of more coolness</a> <small> The killer app for JavaScript in the 90s was...</small></li><li><a href='http://drnicwilliams.com/2007/08/12/magiccgi/' rel='bookmark' title='Permanent Link: MagicCGI shows OpenID user count'>MagicCGI shows OpenID user count</a> <small> In the last 20 days, 43 people have used...</small></li><li><a href='http://drnicwilliams.com/2006/08/29/yehuda-katz-starts-a-blog/' rel='bookmark' title='Permanent Link: Yehuda Katz starts a blog'>Yehuda Katz starts a blog</a> <small>Yehuda is the creator of autoDB &#8211; the wonderful admin...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>It took 4 hours to return from the town of Strängnäs to Stockholm via train. Normally, its 40 minutes. The train never turned up. 4 * 60 &#8211; 40 = 200 minutes of non-travel.</p>
<p>Stuck in a train station for 200 minutes I tackled a problem that has irked me for some time.</p>
<p>In my blog comments, when I reply to someone else&#8217;s comment I&#8217;ll normally use the syntax: &#8220;<em>@chris &#8211; thanks for the kind feedback, I&#8217;ll send the money via paypal</em>&#8220;.</p>
<p>And then Chris says &#8220;<em>@Dr Nic &#8211; yeah, send it to the usual account; the tax man will never find it</em>&#8220;.</p>
<p>And then I say &#8220;<em>@chris &#8211; no problem</em>&#8220;.</p>
<p>Its not that &#8220;@chris&#8221; is difficult to spell, but I&#8217;ve used IRC and Gmail long enough that I like auto-completion. The absence of auto-completion in Skype irks me too.</p>
<p>What I really want is:</p>
<blockquote><p>&#8220;@c&#8221; + TAB expands to &#8220;@chris &#8211; &#8220;</p></blockquote>
<p>So that&#8217;s what I now have. And its neat.</p>
<p><a id="p201" rel="attachment" class="imagelink" href="http://drnicwilliams.com/2007/06/30/autocompleter-for-blog-comments/demo-of-auto-completer/" title="Demo of auto-completer"><img id="image201" src="http://drnicwilliams.com/wp-content/uploads/2007/06/autocompleter.png" alt="Demo of auto-completer" /></a></p>
<p>Unfortunately, the first person to leave a comment below won&#8217;t have anyone to reply to, and so theoretically wouldn&#8217;t get to experience the joys of the feature, that is so awesome and sexy that my very own wife called: </p>
<blockquote><p>&#8220;That&#8217;s nice dear, now help with dinner&#8221;.</p></blockquote>
<p>So, by default &#8220;Nic&#8221;, &#8220;Dr Nic&#8221;, &#8220;drnic&#8221; are available. The 2nd commenter will get these + the name of the 1st commenter. The 3rd commenter will get&#8230; hehe, you thought I was going to type that out.</p>
<p>Here&#8217;s what you&#8217;ll see when you save your comments:</p>
<p><img id="image202" src="http://drnicwilliams.com/wp-content/uploads/2007/06/autocomplete-test.png" alt="Testing Autocompleter" /></p>
<h3>Public release</h3>
<p>Its currently implemented for Wordpress, using Prototype/Scriptaculous. Well it works on my Wordpress theme. It figures out the auto-completion list from the HTML, not from the blog/forum server.</p>
<p>I&#8217;m not sure how different everyone&#8217;s HTML is for their comment blocks. That makes it tricky to release the conde at the moment for general consumption. You might be an HTML guru and make it work, but your sister isn&#8217;t. </p>
<p>So, can you please comment below (wink wink) with the name of your blog software, and include your blog url in the URL field. I might be asking for grief here, but I&#8217;ll scope out everyone&#8217;s blog comment HTML and see how different/similar they are.</p>
<p>BUT!&#8230;</p>
<p>If someone in the comments has already mentioned your blog software (Wordpress, Mephisto, etc) then you MUST reply to their comment. If you are first to comment with your blog software, then use &#8220;@Dr Nic&#8221; instead.</p>
<p>This is life-or-death critical as it gives you an excuse to play with the auto-completer thingy. Lives are at stake here people!</p>
<p>Don&#8217;t have a blog, but want to comment anyway to play with it in all its snazziness? Go for gold.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2008/05/03/github-badge-for-your-blog/' rel='bookmark' title='Permanent Link: GitHub Badge for your Blog with 100% guarantee of more coolness'>GitHub Badge for your Blog with 100% guarantee of more coolness</a> <small> The killer app for JavaScript in the 90s was...</small></li><li><a href='http://drnicwilliams.com/2007/08/12/magiccgi/' rel='bookmark' title='Permanent Link: MagicCGI shows OpenID user count'>MagicCGI shows OpenID user count</a> <small> In the last 20 days, 43 people have used...</small></li><li><a href='http://drnicwilliams.com/2006/08/29/yehuda-katz-starts-a-blog/' rel='bookmark' title='Permanent Link: Yehuda Katz starts a blog'>Yehuda Katz starts a blog</a> <small>Yehuda is the creator of autoDB &#8211; the wonderful admin...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/06/30/autocompleter-for-blog-comments/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</title>
		<link>http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/</link>
		<comments>http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/#comments</comments>
		<pubDate>Thu, 12 Apr 2007 21:26:17 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[DSL]]></category>
		<category><![CDATA[Magic Models]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Trick]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/</guid>
		<description><![CDATA[At this point in time there’s no facility in Rails to talk to more than one database at a time.
Alex Payne
I possibly have such a facility. Perhaps it will help, and I will get some DHH-love and perhaps a free Twitter account for my troubles. Or perhaps a t-shirt.
As a bonus, the solution even includes [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' rel='bookmark' title='Permanent Link: Using CoffeeScript in Rails and even on Heroku'>Using CoffeeScript in Rails and even on Heroku</a> <small>I&#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for...</small></li><li><a href='http://drnicwilliams.com/2009/11/03/first-look-at-rails-3-0-pre/' rel='bookmark' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li><li><a href='http://drnicwilliams.com/2009/10/07/rails-themes-can-remember-things/' rel='bookmark' title='Permanent Link: Rails themes can remember things'>Rails themes can remember things</a> <small>I was getting annoyed at having to remember all the...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<blockquote><p>At this point in time there’s no facility in Rails to talk to more than one database at a time.</p></blockquote>
<p><cite><a href="http://www.radicalbehavior.com/5-question-interview-with-twitter-developer-alex-payne/">Alex Payne</a></cite></p>
<p>I possibly have such a <em>facility</em>. Perhaps it will help, and I will get some <a href="http://www.loudthinking.com/arc/000608.html">DHH-love</a> and perhaps a free <a href="http://www.twitter.com">Twitter</a> account for my troubles. Or perhaps a t-shirt.</p>
<p>As a bonus, the solution even includes decent Ruby-fu syntax. So, if you&#8217;re just here for the view:</p>
<pre>class PeopleController < ApplicationController
  def index
    @people = conn::Person.find(:all)
  end
end
</pre>
<p>That code just there solves all our problems. It will invoke Person.find(:all) on a random database connection to (assumably) a clone database. Awesomeness I think. I hope it helps Twitter and all the Twit-sers (or whatever you call a user of Twitter).</p>
<p>This solution comes from the <a href="http://magicmodels.rubyforge.org/magic_multi_connections">magic_multi_connections</a> gem.</p>
<h1>What is going on here?</h1>
<p>I think a tutorial is the best way to demonstrate what is happening here. So, let's create a rails app and mix in the <a href="http://magicmodels.rubyforge.org/magic_multi_connections">magic_multi_connections</a> gem.</p>
<p>First, get the gem. Second, create a rails app:</p>
<pre>$ sudo gem install magic_multi_connections
$ rails multi -d sqlite3</pre>
<p>Now edit the <code>config/database.yml</code> file to create some more databases:</p>
<pre>development:
  adapter: sqlite3
  database: db/development.sqlite3
  timeout: 5000

development_clone1:
  adapter: sqlite3
  database: db/development_clone1.sqlite3
  timeout: 5000

development_clone2:
  adapter: sqlite3
  database: db/development_clone2.sqlite3
  timeout: 5000
</pre>
<p>But please pretend these are uber-MySQL clusters or whatever.</p>
<p>Think of <strong>:development</strong> as the <strong>read-write</strong> connection, and the <strong>:development_cloneN</strong> connections are for read-only access.</p>
<p>At the bottom of your <strong>environment.rb</strong> file, add the following:</p>
<pre>
require 'magic_multi_connections'
connection_names = ActiveRecord::Base.configurations.keys.select do |name|
  name =~ /^#{ENV['RAILS_ENV']}_clone/
end
@@connection_pool = connection_names.map do |connection_name|
  Object.class_eval <<-EOS
    module #{connection_name.camelize}
      establish_connection :#{connection_name}
    end
  EOS
  connection_name.camelize.constantize
end
</pre>
<p>Let's test what this gives us in the console:</p>
<pre>$ ruby script/console
>> @@connection_pool
=> [DevelopmentClone1, DevelopmentClone2]
>> DevelopmentClone1.class
=> Module
>> DevelopmentClone1.connection_spec
=> :development_clone1
</pre>
<p>Our new modules will act as connections. One module per connection. The code above gives them names to match the connection names, but its really irrelevant what they are called, thanks to the mysterious <code>conn</code> method.</p>
<p>So, go create some models and some data. I'll use <code>Person</code> as the class here.</p>
<p>To setup the schemas in our clone databases, we'll use <code>rake db:migrate</code>. To do this:</p>
<pre>$ cp config/environments/development.rb config/environments/development_clone1.rb
$ cp config/environments/development.rb config/environments/development_clone2.rb
$ rake db:migrate RAILS_ENV=development
$ rake db:migrate RAILS_ENV=development_clone1
$ rake db:migrate RAILS_ENV=development_clone2
</pre>
<p>To differentiate the databases in our example, assume there are two <code>Person</code> records in the <code>:development</code> database, and none in the two clones. Of course, in real-life, they are clones. You'd have a replicate mechanism in there somewhere.</p>
<p>Now, we can access our normal Rails modules through our connection modules. Magically of course.</p>
<pre>>> ActiveRecord::Base.active_connections.keys
=> []
>> Person.count
=> 2
>> ActiveRecord::Base.active_connections.keys
=> ["ActiveRecord::Base"]
>> DevelopmentClone1::Person.count
=> 0
>> ActiveRecord::Base.active_connections.keys
=> ["ActiveRecord::Base", "DevelopmentClone1::Person"]
</pre>
<p>Wowzers. <code>Person</code> <strong>and</strong> <code>DevelopmentClone1::Person</code> classes? </p>
<p>But note - <code>Person.count => 2</code> and <code>DevelopmentClone1::Person.count => 0</code> - they are accessing different databases. The same class definition <code>Person</code> is being used for multiple database connections. We never defined more <code>Person</code> classes. Just the standard default one in <code>app/models/person.rb</code>.</p>
<p>The <code>active_connections</code> result shows that <code>DevelopmentClone1::Person</code> has its own connection. Yet you never had to manually call <code>DevelopmentClone1::Person.establish_connection :development_clone1</code> - it was called automatically when the class is created.</p>
<p>Of course, <code>DevelopmentClone2::Person</code> is automatically connected to <code>:development_clone2</code>, and so on.</p>
<h2>Behind the scenes</h2>
<p>Let's look at our generated classes:</p>
<pre>$ ruby script/console
>> DevelopmentClone1::Person
=> DevelopmentClone1::Person
>> Person
=> Person
>> DevelopmentClone1::Person.superclass
=> Person
</pre>
<p>That is, there is a <code>DevelopmentClone1::Person</code> class, automagically generated for you, which is a subclass of <code>Person</code>, so it has all its behaviour etc.</p>
<h2>Dynamic connection pools within Rails controllers</h2>
<p>The magic of the <code>conn</code> method will now be revealed:</p>
<pre>$ ruby script/console
>> def conn
>>   @@connection_pool[rand(@@connection_pool.size)]
>> end
>> conn::Person.name
=> "DevelopmentClone2::Person"
>> conn::Person.name
=> "DevelopmentClone1::Person"
</pre>
<p>The <code>conn</code> method randomly returns one of the connection modules. Subsequently, <code>conn::Person</code> returns a Person class that is connected to a random clone database. Booya. Free Twitter swag coming my way.</p>
<p>Place the <code>conn</code> method in the ApplicationController class, and you can get dynamic connection pooling within Rails actions as needed, as in the following example (from the top of the article):</p>
<pre>class PeopleController < ApplicationController
  def index
    @people = conn::Person.find(:all)
  end
end
</pre>
<p>Decent Ruby-fu, I think. Certainly better than manually calling <code>establish_connection</code> on model classes before each call (or in a <code>before_filter</code> call, I guess).</p>
<h1>This is just a concept</h1>
<p>I know this tutorial above works. But that might be the extent of what I know. Let me know if this has any quirks (especially if you solve them), or if this is a stupid idea for implementing connection pooling with nice Ruby syntax.</p>
<p><strong>Hope it helps.</strong></p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' rel='bookmark' title='Permanent Link: Using CoffeeScript in Rails and even on Heroku'>Using CoffeeScript in Rails and even on Heroku</a> <small>I&#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for...</small></li><li><a href='http://drnicwilliams.com/2009/11/03/first-look-at-rails-3-0-pre/' rel='bookmark' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li><li><a href='http://drnicwilliams.com/2009/10/07/rails-themes-can-remember-things/' rel='bookmark' title='Permanent Link: Rails themes can remember things'>Rails themes can remember things</a> <small>I was getting annoyed at having to remember all the...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/feed/</wfw:commentRss>
		<slash:comments>59</slash:comments>
		</item>
	</channel>
</rss>
