<?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>The Scoop &#187; Rails</title>
	<atom:link href="http://blog.thescoop.org/archives/category/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.thescoop.org</link>
	<description>Derek Willis' weblog on investigative and computer-assisted reporting.</description>
	<lastBuildDate>Mon, 12 Jul 2010 13:09:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>The Choice(s)</title>
		<link>http://blog.thescoop.org/archives/2008/06/09/the-choices/</link>
		<comments>http://blog.thescoop.org/archives/2008/06/09/the-choices/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 14:56:14 +0000</pubDate>
		<dc:creator>Derek</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[django]]></category>

		<guid isPermaLink="false">http://blog.thescoop.org/?p=5125</guid>
		<description><![CDATA[A couple of folks have asked me lately whether, having first worked with Django and now with Rails, I would recommend one over the other. I resisted the impulse because, first, I&#8217;m an expert in neither framework and second, because the answer really is: it depends. So, that about wraps it up, eh? Actually, I [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of folks have asked me lately whether, having first worked with <a href="http://www.djangoproject.com">Django</a> and now with <a href="http://www.rubyonrails.com/">Rails</a>, I would recommend one over the other. I resisted the impulse because, first, I&#8217;m an expert in neither framework and second, because the answer really is: it depends. So, that about wraps it up, eh?</p>
<p>Actually, I think it&#8217;s a good think to learn both, or as much stuff as you can, because different approaches and philosophies provide different vantage points for dealing with similar issues. Of course, it&#8217;s probably out of the question that newsroom developers can go to their IT folks and say, &#8220;This week it&#8217;s Django. Next week, Rails. After that, who knows?&#8221;</p>
<p>So if you have to choose, consider these factors:</p>
<ol>
<li>Do you have in-house expertise in either the framework or the underlying language? If so, take advantage of that. I know I&#8217;d still be a Python moron without the near-constant guidance I got from <a href="http://www.holovaty.com/">Adrian</a> when I worked at WPNI. I&#8217;d be more of a Ruby moron without my fellow developers at the Times.</li>
<li>Is this your first time with a programming language? Personally, I found learning Python easier than I expected and I found that learning Ruby was easier because I knew some Python. YMMV, of course.</li>
<li>Are you going to need admin apps for much of what you build? If so, then I think that makes Django more attractive, since the admin is such a nice app and it comes baked-in. (Yes, Rails has scaffolding, but it&#8217;s not designed to be a full-fledged admin out of the box.)</li>
</ol>
<p>Here&#8217;s what you don&#8217;t have to worry about: finding developers that know either Python or Ruby. There are a good number of them, and these frameworks are fun to work with. You don&#8217;t have to worry so much about backend issues: both run fine atop MySQL, Postgres and SQLite databases. SQL Server only? Django&#8217;s not gonna be as helpful, although you could always be the person who helps make support for it a reality.</p>
<p>The main philosophical difference between the two that I see in practice is the <a href="http://en.wikipedia.org/wiki/Convention_over_Configuration">configuration vs. convention thing</a>. Django doesn&#8217;t have, for example, a recommended JavaScript library; it leaves that up to you. Rails also allows you to use pretty much whatever, but it puts Prototype out there as sort of a default that you can override. Your reaction to issues like this will depend a lot on your own personal habits and experiences. So try both (or more). See what you like. Then go with it. Just don&#8217;t forget that there are always other ways of doing things, and you can learn a lot from them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thescoop.org/archives/2008/06/09/the-choices/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Big Nerd Ranch Roundup</title>
		<link>http://blog.thescoop.org/archives/2008/05/11/big-nerd-ranch-roundup/</link>
		<comments>http://blog.thescoop.org/archives/2008/05/11/big-nerd-ranch-roundup/#comments</comments>
		<pubDate>Mon, 12 May 2008 00:52:07 +0000</pubDate>
		<dc:creator>Derek</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.thescoop.org/?p=5116</guid>
		<description><![CDATA[For most of the past week I&#8217;ve been at a Ruby on Rails boot camp conducted by Big Nerd Ranch, and I wanted to share some of my thoughts from the experience. First, if the other courses are like mine, you should go if you can. Being pulled away from work and into an environment [...]]]></description>
			<content:encoded><![CDATA[<p>For most of the past week I&#8217;ve been at a Ruby on Rails boot camp conducted by <a href="http://www.bignerdranch.com/">Big Nerd Ranch</a>, and I wanted to share some of my thoughts from the experience. First, if the other courses are like mine, you should go if you can. Being pulled away from work and into an environment where you can focus on learning is extremely valuable. Having meals and lodging included is huge, because it means all you have to do is show up ready to learn. It didn&#8217;t hurt that I got no cellphone reception while I was there, either.</p>
<p>But most trainings are highly dependent on the instructor, and having <a href="http://www.seebq.com/">Charles Brian Quinn</a> was a great benefit. Yes, CBQ knows his Rails, but maybe more important was that he kept the same energetic and patient demeanor the entire week. Think about it: he was the only instructor for a class that had a wide range of backgrounds and experience, and he was unflappable from 9 am to near 11 p.m. every day. That&#8217;s pretty remarkable, and it helped make the class even better.</p>
<p>The class covered quite a bit of material &#8211; &#8220;as much as [Charles] could possibly cram into five days&#8221;, as the certificate says &#8211; so I don&#8217;t have any complaints about substance. One possible suggestion would be for BNR to do a brief poll of attendees to get a sense of their experiences/backgrounds, and distribute that to the class beforehand. That could help an instructor plan and would also save a few minutes on Monday morning, when we were all raring to go.</p>
<p>In all, I&#8217;d definitely recommend Big Nerd Ranch for its total immersion learning style. Oh, and I&#8217;m thinking of incorporating an afternoon walk into my schedule, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thescoop.org/archives/2008/05/11/big-nerd-ranch-roundup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Assigning Non-Sequential IDs in Rails</title>
		<link>http://blog.thescoop.org/archives/2008/05/08/assigning-non-sequential-ids-in-rails/</link>
		<comments>http://blog.thescoop.org/archives/2008/05/08/assigning-non-sequential-ids-in-rails/#comments</comments>
		<pubDate>Fri, 09 May 2008 01:04:51 +0000</pubDate>
		<dc:creator>Derek</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.thescoop.org/?p=5112</guid>
		<description><![CDATA[Before I forget this, I have to write it down, or next time I&#8217;ll be bugging my co-workers for the answer. Let&#8217;s say you&#8217;ve got a table in your database that has a (gasp!) non-sequential ID. Non-numeric, even (horrors!). And you want to build a form to input records, including a specific ID. Passing the [...]]]></description>
			<content:encoded><![CDATA[<p>Before I forget this, I have to write it down, or next time I&#8217;ll be bugging my co-workers for the answer. Let&#8217;s say you&#8217;ve got a table in your database that has a (gasp!) non-sequential ID. Non-numeric, even (horrors!). And you want to build a form to input records, including a specific ID. Passing the handy params hash in full to an Object.create method call doesn&#8217;t work; ID is protected from mass-assignment even if you try to expose it via attr_accessible.</p>
<p>So instead of calling create, call Object.new and pass in the individual params <em>except</em> the ID. Then, on the next line, assign ID and then call save. Voila.</p>
<p>In action, then:</p>
<p><code></p>
<p>    @person = Person.new(:first_name => params["person"]["first_name"], :last_name => params["person"]["last_name"])<br />
    @person.id = params["person"]["id"]<br />
    @person.save<br />
</code></p>
<p>Not that I recommend this for external apps, mind you. But it might come in handy in some circumstances.</p>
<p><em>Update: Aron suggested that this could be done without passing individual params items, and he&#8217;s right. You&#8217;d just have to pull out the ID first and assign it temporarily, then pass the entire params["person"] hash in our example to the create call and finally add the ID element back before saving.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thescoop.org/archives/2008/05/08/assigning-non-sequential-ids-in-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Big Nerd Ranch, Day 2</title>
		<link>http://blog.thescoop.org/archives/2008/05/06/big-nerd-ranch-day-2/</link>
		<comments>http://blog.thescoop.org/archives/2008/05/06/big-nerd-ranch-day-2/#comments</comments>
		<pubDate>Tue, 06 May 2008 23:32:55 +0000</pubDate>
		<dc:creator>Derek</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.thescoop.org/?p=5110</guid>
		<description><![CDATA[Goodies from today: Using partials with bject and not :locals (no need to put the instance variable in every controller that will make use of a partial). Plus, collection in partials to display tables of data, for example. And partial _counter, too. (ie, widget_counter). Dang, I had no idea. Ok, I&#8217;m finally clear on setting [...]]]></description>
			<content:encoded><![CDATA[<p>Goodies from today:</p>
<ul>
<li>Using partials with <img src='http://blog.thescoop.org/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> bject and not :locals (no need to put the instance variable in every controller that will make use of a partial). Plus, collection in partials to display tables of data, for example. And partial _counter, too. (ie, widget_counter). Dang, I had no idea.</li>
<li>Ok, I&#8217;m finally clear on setting up HABTM associations. Finally.</li>
<li>Route names: another thing that you don&#8217;t really realize are more valuable than they appear.</li>
<li>Beginning to understand how Rails handles resources as well.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.thescoop.org/archives/2008/05/06/big-nerd-ranch-day-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Big Nerd Ranch, Day 1</title>
		<link>http://blog.thescoop.org/archives/2008/05/05/big-nerd-ranch-day-1/</link>
		<comments>http://blog.thescoop.org/archives/2008/05/05/big-nerd-ranch-day-1/#comments</comments>
		<pubDate>Mon, 05 May 2008 23:58:23 +0000</pubDate>
		<dc:creator>Derek</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.thescoop.org/?p=5108</guid>
		<description><![CDATA[Today was my first day at the Ruby on Rails class at Big Nerd Ranch, where I&#8217;m joined by Aron. The setting (and weather) is beautiful, and while we got off to a slow start this morning, I&#8217;ve picked up a couple of useful things that I hadn&#8217;t known about Rails (which only leaves about [...]]]></description>
			<content:encoded><![CDATA[<p>Today was my first day at the <a href="http://www.bignerdranch.com/classes/ruby.shtml">Ruby on Rails class at Big Nerd Ranch</a>, where I&#8217;m joined by <a href="http://www.frozenhellscape.org/">Aron</a>. The setting (and weather) is beautiful, and while we got off to a slow start this morning, I&#8217;ve picked up a couple of useful things that I hadn&#8217;t known about Rails (which only leaves about a billion more). A brief roundup:</p>
<ul>
<li>.map { block } is plenty cool. .map(&#038;:symbol) looks odd, but is more succinct.</li>
<li>I now realize why you might render to a template. Cool.</li>
<li>Array has a .to_csv method. Nice.</li>
<li>Creating a new logger object and having it send to STDOUT helps make script/console more helpful.</li>
<li>I now realize why flash is really useful.</li>
<li>Controllers can figure out a url from an instance variable, apparently (Rails 2.0)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.thescoop.org/archives/2008/05/05/big-nerd-ranch-day-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bulk MySQL Imports in Rails</title>
		<link>http://blog.thescoop.org/archives/2008/03/26/bulk-mysql-imports-in-rails/</link>
		<comments>http://blog.thescoop.org/archives/2008/03/26/bulk-mysql-imports-in-rails/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 17:16:55 +0000</pubDate>
		<dc:creator>Derek</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.thescoop.org/?p=5095</guid>
		<description><![CDATA[In which I praise the utility of ar-extensions for bulk MySQL inserts.]]></description>
			<content:encoded><![CDATA[<p>Thanks to a handy and very cool plugin by <a href="http://www.continuousthinking.com/">Zach Dennis</a> called <a href="http://agilewebdevelopment.com/plugins/ar_extensions">ar-extensions</a>, I can do bulk loading in MySQL inside a Rails app. In practice, that can mean cutting the time for loading thousands of rows by half or more. No more hitting the DB each time you save an object via an iterative process. <a href="http://www.igvita.com/2007/07/11/efficient-updates-data-import-in-rails/">Ilya Grigorik</a> has a great example of ar-extensions in action.</p>
<p>One thing that I noticed was that in a rake task, requiring ar-extensions right at the top of the file, before the environment was loaded, resulted in a MySQL error (this occurred on MySQL 5.0 and 5.1). A colleague got it to work by important individual functions within ar-extensions, but I was able to load the entire plugin inside the task after I established a connection to the database. Like this:<br />
<code><br />
  task :some_task => :environment do<br />
    ActiveRecord::Base.establish_connection()<br />
    require 'ar-extensions'<br />
</code><br />
Not the cleanest way, perhaps, but it works, and gives you access to all of ar-extensions goodies, which include some ORM syntax that can keep you from jumping into SQL in the :conditions portion of a ActiveRecord find. So, instead of :</p>
<p><code>Thing.find :all, :conditions => ['begin_date > ?', date]</code></p>
<p>You can write something like:</p>
<p><code>Thing.find :all, :conditions => { begin_date_gt => date }</code></p>
<p>Ar-extensions also provides a to_csv functionality to enable quick CSV dumping.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thescoop.org/archives/2008/03/26/bulk-mysql-imports-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting with Rails</title>
		<link>http://blog.thescoop.org/archives/2008/01/11/starting-with-rails/</link>
		<comments>http://blog.thescoop.org/archives/2008/01/11/starting-with-rails/#comments</comments>
		<pubDate>Fri, 11 Jan 2008 17:43:20 +0000</pubDate>
		<dc:creator>Derek</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.thescoop.org/archives/2008/01/11/starting-with-rails/</guid>
		<description><![CDATA[So as part of my new job I&#8217;m learning to use Rails, and by extension, the Ruby language. Both have been easier to pick up, at least initially, then I had expected. For that, I&#8217;m sure I have my experiences with Python and Django to thank: many concepts are similar, with sometimes similar syntax. I [...]]]></description>
			<content:encoded><![CDATA[<p>So as part of my new job I&#8217;m learning to use <a href="http://www.rubyonrails.org/">Rails</a>, and by extension, the <a href="http://www.ruby-lang.org/en/">Ruby language</a>. Both have been easier to pick up, at least initially, then I had expected. For that, I&#8217;m sure I have my experiences with <a href="http://www.python.org/">Python</a> and <a href="http://www.djangoproject.com">Django</a> to thank: many concepts are similar, with sometimes similar syntax.</p>
<p>I started out by reading a book on <a href="http://ar.rubyonrails.com/">Active Record</a>, which is the ORM for Rails, and I would suggest that to anybody coming to Rails from a database background, because that way you&#8217;re not struggling to pick up both database concepts and Rails/Ruby syntax. Migrations? Good. Rake tasks? Good. <a href="http://apress.com/book/view/1590598474">The book itself</a> is a decent practical guide, <a href="http://blog.hasmanythrough.com/2007/10/29/book-review-pro-active-record">though not perfect</a>, and will be a useful reference for me as I progress.</p>
<p>A very helpful book for me has been <a href="http://www.manning.com/black/">David Black&#8217;s &#8220;Ruby for Rails&#8221;</a>, which is a great guide to syntax and concepts for people like me who are new to these things. On many levels, Ruby is elegant and makes a great deal of sense.</p>
<p>The other resource that I couldn&#8217;t do without is my colleagues, all of whom are much better-versed in Ruby and Rails than I am. Learning this in isolation would be a much greater challenge.</p>
<p>I&#8217;ve got a lingering preference for the url layout of Django, which allows uses regular expressions to construct any kind of url I&#8217;d like, and I&#8217;m sure I&#8217;ll get more comfortable with Rails&#8217; routing and controller syntax as I get further into those areas. And yes, there is that magic, too, which has its ups and downs. Suffice to say that I&#8217;ll still be using Django for personal stuff, but you&#8217;ll see me experiment with Rails outside work as well.</p>
<p>In December I was in New York and went with one of the nytimes.com developers to the <a href="http://nycruby.org/wiki/">RubyNYC</a> meeting, where features of Rails 2 were being discussed. It was an <a href="http://www.brynary.com/2007/12/12/what-s-new-in-rails-2-slides-posted">interesting presentation</a> &#8211; much of it over my head &#8211; but one of the points that grabbed my attention was a brief discussion of the use of slugs in Rails. Slugs? <a href="http://www.djangoproject.com/documentation/model-api/#slugfield">Where have I heard that before</a>? Nice to see a newspaper term work its way further into the Web.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thescoop.org/archives/2008/01/11/starting-with-rails/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
