<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Rails Coach</title>
	
	<link>http://railscoach.com</link>
	<description>Your Playbook for Ruby on Rails</description>
	<lastBuildDate>Tue, 20 Nov 2012 01:12:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
<!-- podcast_generator="Blubrry PowerPress/4.0.4" -->
	<itunes:summary>A series of short discussions on topics related to Ruby and Rails. Topics range from basic Ruby and Rails concepts to advanced topics.</itunes:summary>
	<itunes:author>Charles Max Wood</itunes:author>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://railscoach.com/wp-content/uploads/2011/04/railscoach_itunes.jpg" />
	<itunes:subtitle>Rails Coach Podcast</itunes:subtitle>
	<image>
		<title>Rails Coach</title>
		<url>http://railscoach.com/wp-content/plugins/powerpress/rss_default.jpg</url>
		<link>http://railscoach.com</link>
	</image>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/railscoachpodcast" /><feedburner:info uri="railscoachpodcast" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><media:copyright>(c) Intentional Excellence Productions LLC</media:copyright><media:thumbnail url="http://railscoach.com/wp-content/uploads/2011/04/railscoach_itunes.jpg" /><media:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</media:keywords><media:category scheme="http://www.itunes.com/dtds/podcast-1.0.dtd">Technology/Software How-To</media:category><itunes:owner><itunes:email>chuck@teachmetocode.com</itunes:email><itunes:name>Charles Max Wood</itunes:name></itunes:owner><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><itunes:category text="Technology"><itunes:category text="Software How-To" /></itunes:category><item>
		<title>Reboot</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/T9y8GjIuxXA/</link>
		<comments>http://railscoach.com/reboot/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 06:00:23 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=204</guid>
		<description><![CDATA[Today, just a quick message outlining the future of Rails Coach.]]></description>
			<content:encoded><![CDATA[<p>Today, just a quick message outlining the future of Rails Coach.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/T9y8GjIuxXA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/reboot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RCReboot.mp3" length="3036452" type="audio/mpeg" />
		<itunes:subtitle>Today, just a quick message outlining the future of Rails Coach.</itunes:subtitle>
		<itunes:summary>Today, just a quick message outlining the future of Rails Coach.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>2:32</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RCReboot.mp3" fileSize="3036452" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/reboot/</feedburner:origLink></item>
		<item>
		<title>032 RC CoffeeScript</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/kqtQS9JIU6A/</link>
		<comments>http://railscoach.com/032-rc-coffeescript/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 16:00:02 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=199</guid>
		<description><![CDATA[CoffeeScript is a language written by Jeremy Ashkenas that compiles to Javascript. Its syntax is much more friendly than native JavaScript. Especially if you&#8217;re used to languages like Ruby or Python. As or Rails 3.1, CoffeeScript is available by default and a coffeescript file is created in /app/assets/javascripts every time you run the scaffold generator. [...]]]></description>
			<content:encoded><![CDATA[<p>CoffeeScript is a language written by Jeremy Ashkenas that compiles to Javascript. Its syntax is much more friendly than native JavaScript. Especially if you&#8217;re used to languages like Ruby or Python.</p>
<p>As or Rails 3.1, CoffeeScript is available by default and a coffeescript file is created in /app/assets/javascripts every time you run the scaffold generator.</p>
<p>A few of my favorite features of the language are:</p>
<ul>
<li>I can ignore parenthesis (mostly), semi-colons, and curly braces</li>
<li>Function notation</li>
<li>Objects with nested notation</li>
<li>Variable safety (not creating globals)</li>
<li>Splats on lists</li>
<li>Classes</li>
<li>Always returns last expression</li>
<li>String interpolation</li>
</ul>
<p>I don&#8217;t like:</p>
<ul>
<li>Operator aliases</li>
</ul>
<p>Resources:</p>
<ul>
<li><a href="http://coffeescript.org/">CoffeeScript Webpage</a></li>
<li><a href="http://coffeescriptcookbook.com">CoffeeScript Cookbook</a></li>
<li><a href="http://teachmetocode.com/screencasts/coffeescript-basics-a-teach-me-to-code-tutorial/">CoffeeScript Basics (video)</a></li>
<li><a href="http://teachmetocode.com/screencasts/coffeescript-the-cool-parts/">CoffeeScript: The Cool Parts (video)</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/kqtQS9JIU6A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/032-rc-coffeescript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/032RCCoffeeScript.mp3" length="11500238" type="audio/mpeg" />
		<itunes:subtitle>CoffeeScript is a language written by Jeremy Ashkenas that compiles to Javascript. Its syntax is much more friendly than native JavaScript. Especially if you're used to languages like Ruby or Python. - As or Rails 3.1,</itunes:subtitle>
		<itunes:summary>CoffeeScript is a language written by Jeremy Ashkenas that compiles to Javascript. Its syntax is much more friendly than native JavaScript. Especially if you're used to languages like Ruby or Python.

As or Rails 3.1, CoffeeScript is available by default and a coffeescript file is created in /app/assets/javascripts every time you run the scaffold generator.

A few of my favorite features of the language are:

	I can ignore parenthesis (mostly), semi-colons, and curly braces
	Function notation
	Objects with nested notation
	Variable safety (not creating globals)
	Splats on lists
	Classes
	Always returns last expression
	String interpolation

I don't like:

	Operator aliases

Resources:

	CoffeeScript Webpage
	CoffeeScript Cookbook
	CoffeeScript Basics (video)
	CoffeeScript: The Cool Parts (video)</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>7:59</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/032RCCoffeeScript.mp3" fileSize="11500238" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/032-rc-coffeescript/</feedburner:origLink></item>
		<item>
		<title>031 RC Generators</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/xZHjLOdHdNo/</link>
		<comments>http://railscoach.com/031-rc-generators/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 20:46:11 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Rails Concepts]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=192</guid>
		<description><![CDATA[A generator is a way of creating code from the command line. Rails has several of these built in, including generators for models, controllers, tests, helpers, scaffold (models, views, and controllers that support Rails&#8217; RESTful routing), and much more. Generators are actually relatively simple. They are made up of two parts. The generator itself, and [...]]]></description>
			<content:encoded><![CDATA[<p>A generator is a way of creating code from the command line. Rails has several of these built in, including generators for models, controllers, tests, helpers, scaffold (models, views, and controllers that support Rails&#8217; RESTful routing), and much more.</p>
<p>Generators are actually relatively simple. They are made up of two parts. The generator itself, and the generator&#8217;s templates. In the Ruby on Rails source code there&#8217;s an <a href="https://github.com/rails/rails/blob/539752a54cf3426c98e65136206df9f9553d9e73/railties/lib/rails/generators/rails/assets/assets_generator.rb">assets generator</a> and the <a href="https://github.com/rails/rails/blob/539752a54cf3426c98e65136206df9f9553d9e73/railties/lib/rails/generators/rails/assets/templates/javascript.js">javascript template</a> and <a href="https://github.com/rails/rails/blob/539752a54cf3426c98e65136206df9f9553d9e73/railties/lib/rails/generators/rails/assets/templates/stylesheet.css">stylesheet templates</a> it uses.</p>
<p>I&#8217;ve also created a model generator for my Sandra ORM. You can find it <a href="https://github.com/charlesmaxwood/sandra-rails/tree/master/lib/generators/sandra/model">here</a>.</p>
<p>Understanding how models work, you can see how simple it is for the Rails Core Team to build in generators for other things like models, controllers, helpers, tests, assets, mailers, etc.</p>
<p>To see the full list of generators available in a Rails application run `rails generate` or `rails g`.</p>
<p>To create your own generators in your project, put them under /lib/generators or better yet, use the generator for generators like this: `rails generate generator widget` and you&#8217;ll get a widget generator all set up for you in the /lib/generators folder that&#8217;s ready for you to customize.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/xZHjLOdHdNo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/031-rc-generators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC31Generators.mp3" length="8217494" type="audio/mpeg" />
		<itunes:subtitle>A generator is a way of creating code from the command line. Rails has several of these built in, including generators for models, controllers, tests, helpers, scaffold (models, views, and controllers that support Rails' RESTful routing), and much more.</itunes:subtitle>
		<itunes:summary>A generator is a way of creating code from the command line. Rails has several of these built in, including generators for models, controllers, tests, helpers, scaffold (models, views, and controllers that support Rails' RESTful routing), and much more.

Generators are actually relatively simple. They are made up of two parts. The generator itself, and the generator's templates. In the Ruby on Rails source code there's an assets generator and the javascript template and stylesheet templates it uses.

I've also created a model generator for my Sandra ORM. You can find it here.

Understanding how models work, you can see how simple it is for the Rails Core Team to build in generators for other things like models, controllers, helpers, tests, assets, mailers, etc.

To see the full list of generators available in a Rails application run `rails generate` or `rails g`.

To create your own generators in your project, put them under /lib/generators or better yet, use the generator for generators like this: `rails generate generator widget` and you'll get a widget generator all set up for you in the /lib/generators folder that's ready for you to customize.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>5:42</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC31Generators.mp3" fileSize="8217494" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/031-rc-generators/</feedburner:origLink></item>
		<item>
		<title>030 RC NoSQL</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/wr875s132_E/</link>
		<comments>http://railscoach.com/030-rc-nosql/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 01:28:17 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=188</guid>
		<description><![CDATA[NoSQL is a terrible term for a collection of widely varied databases. You have key-value stores like Redis, Tokyo Cabinet, Memcached, etc. You also have document databases like couchDB and mongoDB. Finally you have column based systems like Cassandra. And still others like HBase. In a lot of cases, there are gems for these. I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>NoSQL is a terrible term for a collection of widely varied databases. You have key-value stores like Redis, Tokyo Cabinet, Memcached, etc. You also have document databases like couchDB and mongoDB. Finally you have column based systems like Cassandra. And still others like HBase.</p>
<p>In a lot of cases, there are gems for these. I&#8217;ve used several of them such as the gems for managing Cassandra, couchDB, and mongoDB.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/wr875s132_E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/030-rc-nosql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC030NoSQL.mp3" length="14160738" type="audio/mpeg" />
		<itunes:subtitle>NoSQL is a terrible term for a collection of widely varied databases. You have key-value stores like Redis, Tokyo Cabinet, Memcached, etc. You also have document databases like couchDB and mongoDB. Finally you have column based systems like Cassandra.</itunes:subtitle>
		<itunes:summary>NoSQL is a terrible term for a collection of widely varied databases. You have key-value stores like Redis, Tokyo Cabinet, Memcached, etc. You also have document databases like couchDB and mongoDB. Finally you have column based systems like Cassandra. And still others like HBase.

In a lot of cases, there are gems for these. I've used several of them such as the gems for managing Cassandra, couchDB, and mongoDB.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>9:50</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC030NoSQL.mp3" fileSize="14160738" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/030-rc-nosql/</feedburner:origLink></item>
		<item>
		<title>028 RC Backbone.js</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/_DtWocrgkJc/</link>
		<comments>http://railscoach.com/028-backbone-js/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 03:25:24 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=179</guid>
		<description><![CDATA[I&#8217;ve been using Backbone.js for a few weeks and really like the way it helps you manage your data on the client side. It&#8217;s also a terrific way to keep your UI in sync when your data changes through Javascript events.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Backbone.js for a few weeks and really like the way it helps you manage your data on the client side. It&#8217;s also a terrific way to keep your UI in sync when your data changes through Javascript events.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/_DtWocrgkJc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/028-backbone-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC028BackboneJS.mp3" length="10477692" type="audio/mpeg" />
		<itunes:subtitle>I've been using Backbone.js for a few weeks and really like the way it helps you manage your data on the client side. It's also a terrific way to keep your UI in sync when your data changes through Javascript events.</itunes:subtitle>
		<itunes:summary>I've been using Backbone.js for a few weeks and really like the way it helps you manage your data on the client side. It's also a terrific way to keep your UI in sync when your data changes through Javascript events.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>7:16</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC028BackboneJS.mp3" fileSize="10477692" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/028-backbone-js/</feedburner:origLink></item>
		<item>
		<title>029 RC Ruby-doc.org</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/aSMiDRSc8LM/</link>
		<comments>http://railscoach.com/029-rc-ruby-doc-org/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 21:24:35 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=182</guid>
		<description><![CDATA[One of the most handy websites out there for people trying to find specific API&#8217;s in Ruby is ruby-doc.org. From the main page, you can search or select your Ruby version. From the core page, you can narrow down the class or method you&#8217;re looking for. From the std-lib page, you can read docs and [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most handy websites out there for people trying to find specific API&#8217;s in Ruby is ruby-doc.org.</p>
<p>From the main page, you can search or select your Ruby version.</p>
<p>From the core page, you can narrow down the class or method you&#8217;re looking for.</p>
<p>From the std-lib page, you can read docs and see where different aspects of the programming language are implemented.</p>
<p>On each class&#8217; page, you can find the specific functionality you need in the menu on the left.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/aSMiDRSc8LM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/029-rc-ruby-doc-org/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC029RubyDocOrg.mp3" length="10788466" type="audio/mpeg" />
		<itunes:subtitle>One of the most handy websites out there for people trying to find specific API's in Ruby is ruby-doc.org. - From the main page, you can search or select your Ruby version. - From the core page, you can narrow down the class or method you're looking ...</itunes:subtitle>
		<itunes:summary>One of the most handy websites out there for people trying to find specific API's in Ruby is ruby-doc.org.

From the main page, you can search or select your Ruby version.

From the core page, you can narrow down the class or method you're looking for.

From the std-lib page, you can read docs and see where different aspects of the programming language are implemented.

On each class' page, you can find the specific functionality you need in the menu on the left.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>7:29</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC029RubyDocOrg.mp3" fileSize="10788466" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/029-rc-ruby-doc-org/</feedburner:origLink></item>
		<item>
		<title>027 RC Vim</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/TTbmXPf1Kco/</link>
		<comments>http://railscoach.com/027-rc-vim/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 19:25:11 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=173</guid>
		<description><![CDATA[I&#8217;ve been using VIM for a while to do my development. It&#8217;s a terrific text editor that has been around for quite some time. Here&#8217;s the rundown of what I&#8217;ve got set up. MacVim: http://code.google.com/p/macvim/ Janus: https://github.com/carlhuda/janus I&#8217;ve also found a few resources to help me get better with Vim as well. Here are some of my [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using VIM for a while to do my development. It&#8217;s a terrific text editor that has been around for quite some time. Here&#8217;s the rundown of what I&#8217;ve got set up.</p>
<p>MacVim: <a href="http://code.google.com/p/macvim/">http://code.google.com/p/macvim/</a></p>
<p>Janus: <a href="https://github.com/carlhuda/janus">https://github.com/carlhuda/janus</a></p>
<p>I&#8217;ve also found a few resources to help me get better with Vim as well. Here are some of my favorites:</p>
<p>VimCasts: <a href="http://vimcasts.org/">http://vimcasts.org/</a></p>
<p>VimGolf: <a href="http://vimgolf.com">http://vimgolf.com</a></p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/TTbmXPf1Kco" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/027-rc-vim/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC027Vim.mp3" length="17473093" type="audio/mpeg" />
		<itunes:subtitle>I've been using VIM for a while to do my development. It's a terrific text editor that has been around for quite some time. Here's the rundown of what I've got set up. - MacVim: http://code.google.com/p/macvim/ - Janus: https://github.</itunes:subtitle>
		<itunes:summary>I've been using VIM for a while to do my development. It's a terrific text editor that has been around for quite some time. Here's the rundown of what I've got set up.

MacVim: http://code.google.com/p/macvim/

Janus: https://github.com/carlhuda/janus

I've also found a few resources to help me get better with Vim as well. Here are some of my favorites:

VimCasts: http://vimcasts.org/

VimGolf: http://vimgolf.com</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>9:06</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC027Vim.mp3" fileSize="17473093" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/027-rc-vim/</feedburner:origLink></item>
		<item>
		<title>026 RC Counter Caches</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/ERTLGIknGZE/</link>
		<comments>http://railscoach.com/026-rc-counter-caches/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 03:56:42 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=168</guid>
		<description><![CDATA[A counter cache is a handy way to speed up queries where you only need the number of an associated model rather than the entire collection. In your code, you might see something like this: @post.comments.count When you run this code, you wind up with another query to the database to get that number. That&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>A counter cache is a handy way to speed up queries where you only need the number of an associated model rather than the entire collection. In your code, you might see something like this:</p>
<p>@post.comments.count</p>
<p>When you run this code, you wind up with another query to the database to get that number. That&#8217;s not a big deal until you have that count being called for each post in your stream. To avoid this, you can use a counter cache.</p>
<p>To use the counter cache, add a &lt;other_model_table&gt;_count to the primary model&#8217;s table. In this example, it would be called &#8220;comments_count&#8221;.</p>
<pre>class AddCounterCacheToPosts &lt; ActiveRecord::Migration
  def change
    add_column :posts, :counter_cache, :integer
  end
end</pre>
<p>With that migration in place, all you need to do from there is add :counter_cache =&gt; true to your other model—in this case Comment.</p>
<pre>class Comment &lt; ActiveRecord::Base
  belongs_to :post, :counter_cache =&gt; true
end</pre>
<p>Now, whenever you create or delete a new comment for a post, it&#8217;ll update that counter_cache column on the posts table.</p>
<p>A few things to keep in mind are:</p>
<ol>
<li>If you&#8217;re adding this to an existing system, you&#8217;ll probably have to add a data migration to set the counts.</li>
<li>This number is not checked each time it&#8217;s changed, so if you change the number, you&#8217;ll get results in the future relative to that number.</li>
</ol>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/ERTLGIknGZE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/026-rc-counter-caches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC026CounterCache.mp3" length="7654576" type="audio/mpeg" />
		<itunes:subtitle>A counter cache is a handy way to speed up queries where you only need the number of an associated model rather than the entire collection. In your code, you might see something like this: - @post.comments.count - When you run this code,</itunes:subtitle>
		<itunes:summary>A counter cache is a handy way to speed up queries where you only need the number of an associated model rather than the entire collection. In your code, you might see something like this:

@post.comments.count

When you run this code, you wind up with another query to the database to get that number. That's not a big deal until you have that count being called for each post in your stream. To avoid this, you can use a counter cache.

To use the counter cache, add a &lt;other_model_table&gt;_count to the primary model's table. In this example, it would be called "comments_count".
class AddCounterCacheToPosts &lt; ActiveRecord::Migration
  def change
    add_column :posts, :counter_cache, :integer
  end
end
With that migration in place, all you need to do from there is add :counter_cache =&gt; true to your other model—in this case Comment.
class Comment &lt; ActiveRecord::Base
  belongs_to :post, :counter_cache =&gt; true
end
Now, whenever you create or delete a new comment for a post, it'll update that counter_cache column on the posts table.

A few things to keep in mind are:

	If you're adding this to an existing system, you'll probably have to add a data migration to set the counts.
	This number is not checked each time it's changed, so if you change the number, you'll get results in the future relative to that number.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>5:19</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC026CounterCache.mp3" fileSize="7654576" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/026-rc-counter-caches/</feedburner:origLink></item>
		<item>
		<title>025 RC Eager Loading</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/cImulSV_a40/</link>
		<comments>http://railscoach.com/025-rc-eager-loading/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 01:12:18 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[eager loading]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=159</guid>
		<description><![CDATA[Eager loading is a terrific way of speeding up your response times. Let&#8217;s consider a piece of code that pulls a list of associated objects from the database. For example, a view that displays the posts written by a given user: &#60;% @user.posts.each do &#124;post&#124; %&#62; &#60;%= render post %&#62; &#60;% end %&#62; (I know [...]]]></description>
			<content:encoded><![CDATA[<p>Eager loading is a terrific way of speeding up your response times. Let&#8217;s consider a piece of code that pulls a list of associated objects from the database. For example, a view that displays the posts written by a given user:</p>
<pre>&lt;% @user.posts.each do |post| %&gt;
  &lt;%= render post %&gt;
&lt;% end %&gt;</pre>
<p>(I know that partial has a collection option for things like this. I feel that this code sample is more expressive for our discussion.)</p>
<p>In this case, assuming that @user was loaded by calling User.find(1), your Rails application is going to go to the database for each post. So, if the user has 40 posts in the system, the Rails application will make 40 trips to the database to get the posts.</p>
<p>The problem is that if there is any latency on the database connection, it adds up.</p>
<p>The fix for this is the use of the &#8216;includes&#8217; method when querying for the user. User#includes tells the query to pull in whatever associated records you specify in its arguments. So, if we found @user by calling User.includes([:posts]).find(1), it would pull the user&#8217;s record and all of the user&#8217;s posts records and cache all of the user&#8217;s posts on the user&#8217;s object.</p>
<p>The argument for &#8216;includes&#8217; is an array. The objects in the array can be symbols or hashes. Symbols represent that associations the Model has. Hashes are used for including nested associations. For example, if we wanted to pull all of the comments on the user&#8217;s posts. Here&#8217;s another example:</p>
<pre># In the controller
@user = User.includes([:address, :phone_number, {:posts =&gt; [:comments]}]).find(1)

# In the view 
&lt;% @user.posts.each do |post| %&gt;
  &lt;%= render post %&gt;
  &lt;% post.comments.each do |comment| %&gt;
    &lt;%= render comment %&gt;
  &lt;% end %&gt; 
&lt;% end %&gt;</pre>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/cImulSV_a40" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/025-rc-eager-loading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC28EagerLoading.mp3" length="10762030" type="audio/mpeg" />
			<itunes:keywords>database,eager loading</itunes:keywords>
	<itunes:subtitle>Eager loading is a terrific way of speeding up your response times. Let's consider a piece of code that pulls a list of associated objects from the database. For example, a view that displays the posts written by a given user: &lt;% @user.posts.</itunes:subtitle>
		<itunes:summary>Eager loading is a terrific way of speeding up your response times. Let's consider a piece of code that pulls a list of associated objects from the database. For example, a view that displays the posts written by a given user:
&lt;% @user.posts.each do |post| %&gt;
  &lt;%= render post %&gt;
&lt;% end %&gt;
(I know that partial has a collection option for things like this. I feel that this code sample is more expressive for our discussion.)

In this case, assuming that @user was loaded by calling User.find(1), your Rails application is going to go to the database for each post. So, if the user has 40 posts in the system, the Rails application will make 40 trips to the database to get the posts.

The problem is that if there is any latency on the database connection, it adds up.

The fix for this is the use of the 'includes' method when querying for the user. User#includes tells the query to pull in whatever associated records you specify in its arguments. So, if we found @user by calling User.includes([:posts]).find(1), it would pull the user's record and all of the user's posts records and cache all of the user's posts on the user's object.

The argument for 'includes' is an array. The objects in the array can be symbols or hashes. Symbols represent that associations the Model has. Hashes are used for including nested associations. For example, if we wanted to pull all of the comments on the user's posts. Here's another example:
# In the controller
@user = User.includes([:address, :phone_number, {:posts =&gt; [:comments]}]).find(1)

# In the view 
&lt;% @user.posts.each do |post| %&gt;
  &lt;%= render post %&gt;
  &lt;% post.comments.each do |comment| %&gt;
    &lt;%= render comment %&gt;
  &lt;% end %&gt; 
&lt;% end %&gt;</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>7:28</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC28EagerLoading.mp3" fileSize="10762030" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/025-rc-eager-loading/</feedburner:origLink></item>
		<item>
		<title>Rails 3.1 Asset Pipeline</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/oAUYonQC6nM/</link>
		<comments>http://railscoach.com/rails-3-1-asset-pipeline/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 19:23:33 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Assets]]></category>
		<category><![CDATA[assets]]></category>
		<category><![CDATA[CoffeeScript]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=145</guid>
		<description><![CDATA[Assets in Rails before version 3.1 were kept in the /public folder. In Rails 3.1 they&#8217;ve been moved to /app/assets and function in a slightly different way. Here are some of the highlights: Javascript assets written in Coffeescript will now be compiled to Javascript. CSS assets written in SASS or SCSS will now be compiled to [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-125" style="border-style: initial; border-color: initial;" title="railscoach_itunes_small" src="http://railscoach.com/wp-content/uploads/2011/08/railscoach_itunes_small.jpg" alt="" width="200" height="200" /></p>
<p>Assets in Rails before version 3.1 were kept in the /public folder. In Rails 3.1 they&#8217;ve been moved to /app/assets and function in a slightly different way. Here are some of the highlights:</p>
<ul>
<li>Javascript assets written in Coffeescript will now be compiled to Javascript.</li>
<li>CSS assets written in SASS or SCSS will now be compiled to CSS</li>
<li>Other templating languages like ERB can be used in assets</li>
<li>JQuery is now the default Javascript framework in Rails 3.1</li>
<li>You can combine Javascript files with the new directives</li>
<li>Pre-compiled assets</li>
</ul>
<p>When compiling from SASS, SCSS, CoffeeScript, or ERB, you simply add the appropriate extension to your .js or .css file. (.sass, .scss, .coffee, or .erb respectively)</p>
<p>To combine several Javascript files into one file, (for example application.js) just do something like this.</p>
<div><code>//= require jquery<br />
//= require jquery_ujs<br />
//= require_tree .<br />
//= require_directory tooltips</code></div>
<p>&nbsp;</p>
<p>For several CSS files, it&#8217;s the same commands, just *= instead of //= and wrapped in /* &#8230; */. Here&#8217;s a quick example:</p>
<div><code>/*<br />
*= require reset<br />
*= require base<br />
*= require_tree .<br />
*= require_directory tooltips<br />
*/</code></div>
<p>&nbsp;</p>
<p><strong>require</strong> pulls in a file. <strong>require_tree</strong> gets everything in the specified path. <strong>require_directory</strong> pulls in all the files in a given directory (no nesting).</p>
<p>You can precompile your assets by running <strong>bundle exec rake assets:precompile </strong>(For example, if your server doesn&#8217;t have a Javascript runtime on it capable of compiling Coffeescript.)</p>
<p>Here are some resources for CoffeeScript:</p>
<ul>
<li><a href="http://jashkenas.github.com/coffee-script/">The Coffeescript Website</a></li>
<li><a href="http://teachmetocode.com/screencasts/coffeescript-basics-a-teach-me-to-code-tutorial/">CoffeeScript Basics</a> (video)</li>
<li><a href="http://teachmetocode.com/screencasts/coffeescript-the-cool-parts/">CoffeeScript: The Cool Parts</a> (video)</li>
</ul>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/oAUYonQC6nM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/rails-3-1-asset-pipeline/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC24Rails31AssetPipeline_01.mp3" length="13417050" type="audio/mpeg" />
			<itunes:keywords>assets,CoffeeScript,CSS,Javascript,JQuery,rails</itunes:keywords>
	<itunes:subtitle>Assets in Rails before version 3.1 were kept in the /public folder. In Rails 3.1 they've been moved to /app/assets and function in a slightly different way. Here are some of the highlights:  Javascript assets written in Coffeescript will now be comp...</itunes:subtitle>
		<itunes:summary>Assets in Rails before version 3.1 were kept in the /public folder. In Rails 3.1 they've been moved to /app/assets and function in a slightly different way. Here are some of the highlights:

	Javascript assets written in Coffeescript will now be compiled to Javascript.
	CSS assets written in SASS or SCSS will now be compiled to CSS
	Other templating languages like ERB can be used in assets
	JQuery is now the default Javascript framework in Rails 3.1
	You can combine Javascript files with the new directives
	Pre-compiled assets

When compiling from SASS, SCSS, CoffeeScript, or ERB, you simply add the appropriate extension to your .js or .css file. (.sass, .scss, .coffee, or .erb respectively)

To combine several Javascript files into one file, (for example application.js) just do something like this.
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require_directory tooltips
 

For several CSS files, it's the same commands, just *= instead of //= and wrapped in /* ... */. Here's a quick example:
/*
*= require reset
*= require base
*= require_tree .
*= require_directory tooltips
*/
 

require pulls in a file. require_tree gets everything in the specified path. require_directory pulls in all the files in a given directory (no nesting).

You can precompile your assets by running bundle exec rake assets:precompile (For example, if your server doesn't have a Javascript runtime on it capable of compiling Coffeescript.)

Here are some resources for CoffeeScript:

	The Coffeescript Website
	CoffeeScript Basics (video)
	CoffeeScript: The Cool Parts (video)</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>9:19</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC24Rails31AssetPipeline_01.mp3" fileSize="13417050" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/rails-3-1-asset-pipeline/</feedburner:origLink></item>
		<item>
		<title>ActiveRecord Observers</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/qFxF4yQ3fUU/</link>
		<comments>http://railscoach.com/activerecord-observers/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 23:37:37 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[callbacks]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[models]]></category>
		<category><![CDATA[observers]]></category>
		<category><![CDATA[single responsiblity principle]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=140</guid>
		<description><![CDATA[About a month ago, I talked about ActiveRecord Callbacks. Observers are a way of moving callbacks out of the Model. Usually this is done to adhere to the Single Responsibility principle. So, for example, programmers will move sending an email when a record is updated or created to an Observer. class UserObserver &#60; ActiveRecord::Observer def [...]]]></description>
			<content:encoded><![CDATA[<p>About a month ago, I talked about <a href="../activerecord-callbacks/">ActiveRecord Callbacks</a>. Observers are a way of moving callbacks out of the Model. Usually this is done to adhere to the Single Responsibility principle. So, for example, programmers will move sending an email when a record is updated or created to an Observer.</p>
<pre>class UserObserver &lt; ActiveRecord::Observer
 def after_create(user)
   UserMailer.sign_up(user).deliver
 end
end</pre>
<p>&nbsp;</p>
<p>Observers should be included in your app/models folder and named using the same convention as your models. So in this case, this observer would be saved to /app/models/user_observer.rb.</p>
<p>To load the observer in your application, you need to include this line in your config/application.rb</p>
<pre>config.active_record.observers = :user_observer</pre>
<p>&nbsp;</p>
<p>Finally, you can observe more than one model with the same observer.</p>
<pre>class SignUpObserver &lt; ActiveRecord::Observer
 observer :user, :admin

 def after_create(user)
   UserMailer.sign_up(user).deliver
 end
end</pre>
<p>&nbsp;</p>
<p>I personally like Observers when they help keep you from repeating code or increase code readability. In many cases, I simply keep callbacks in models and violate the Single Responsibility Principle.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/qFxF4yQ3fUU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/activerecord-observers/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC23Observers_01.mp3" length="10382828" type="audio/mpeg" />
			<itunes:keywords>activerecord,callbacks,events,models,observers,single responsiblity principle</itunes:keywords>
	<itunes:subtitle>About a month ago, I talked about ActiveRecord Callbacks. Observers are a way of moving callbacks out of the Model. Usually this is done to adhere to the Single Responsibility principle. So, for example, programmers will move sending an email when a re...</itunes:subtitle>
		<itunes:summary>About a month ago, I talked about ActiveRecord Callbacks. Observers are a way of moving callbacks out of the Model. Usually this is done to adhere to the Single Responsibility principle. So, for example, programmers will move sending an email when a record is updated or created to an Observer.
class UserObserver &lt; ActiveRecord::Observer
 def after_create(user)
   UserMailer.sign_up(user).deliver
 end
end
 

Observers should be included in your app/models folder and named using the same convention as your models. So in this case, this observer would be saved to /app/models/user_observer.rb.

To load the observer in your application, you need to include this line in your config/application.rb
config.active_record.observers = :user_observer
 

Finally, you can observe more than one model with the same observer.
class SignUpObserver &lt; ActiveRecord::Observer
 observer :user, :admin

 def after_create(user)
   UserMailer.sign_up(user).deliver
 end
end
 

I personally like Observers when they help keep you from repeating code or increase code readability. In many cases, I simply keep callbacks in models and violate the Single Responsibility Principle.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>7:12</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC23Observers_01.mp3" fileSize="10382828" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/activerecord-observers/</feedburner:origLink></item>
		<item>
		<title>ActiveModel – Making Ruby Classes Behave Like Models</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/037hA2XSYiA/</link>
		<comments>http://railscoach.com/activemodel-making-ruby-classes-behave-like-models/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 17:13:06 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[ActiveModel]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[attributes]]></category>
		<category><![CDATA[callbacks]]></category>
		<category><![CDATA[dirty]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[naming]]></category>
		<category><![CDATA[observers]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[serialization]]></category>
		<category><![CDATA[state machine]]></category>
		<category><![CDATA[translation]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=136</guid>
		<description><![CDATA[I’ve been working on an ORM for Cassandra. One of the things I’ve been using to build the ORM is ActiveModel. ActiveModel gives you modules you can add to your class that makes it behave like an ActiveRecord Model. Here are some of the features you can add to your classes with ActiveModel. Attribute Methods [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been working on an ORM for Cassandra. One of the things I’ve been using to build the ORM is ActiveModel. ActiveModel gives you modules you can add to your class that makes it behave like an ActiveRecord Model.</p>
<p>Here are some of the features you can add to your classes with ActiveModel.</p>
<ul>
<li>Attribute Methods</li>
<li>Callbacks</li>
<li>Dirty Attributes (knowing which attributes have changed)</li>
<li>Naming (allows you to reference the class and model by the object)</li>
<li>Observers</li>
<li>Serialization (to JSON or XML)</li>
<li>State Machine (a really basic one)</li>
<li>Translation</li>
<li>Validations</li>
</ul>
<p>So, if you’re looking to add your Ruby class to a Rails app, or want this sort of behavior in Sinatra, etc. this is a great way to get it.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/037hA2XSYiA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/activemodel-making-ruby-classes-behave-like-models/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC22ActiveModel_01.mp3" length="9922092" type="audio/mpeg" />
			<itunes:keywords>ActiveModel,activerecord,attributes,callbacks,dirty,json,naming,observers,rails,ruby on rails,serialization,state machine</itunes:keywords>
	<itunes:subtitle>I’ve been working on an ORM for Cassandra. One of the things I’ve been using to build the ORM is ActiveModel. ActiveModel gives you modules you can add to your class that makes it behave like an ActiveRecord Model. - </itunes:subtitle>
		<itunes:summary>I’ve been working on an ORM for Cassandra. One of the things I’ve been using to build the ORM is ActiveModel. ActiveModel gives you modules you can add to your class that makes it behave like an ActiveRecord Model.

Here are some of the features you can add to your classes with ActiveModel.

	Attribute Methods
	Callbacks
	Dirty Attributes (knowing which attributes have changed)
	Naming (allows you to reference the class and model by the object)
	Observers
	Serialization (to JSON or XML)
	State Machine (a really basic one)
	Translation
	Validations

So, if you’re looking to add your Ruby class to a Rails app, or want this sort of behavior in Sinatra, etc. this is a great way to get it.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>6:53</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC22ActiveModel_01.mp3" fileSize="9922092" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/activemodel-making-ruby-classes-behave-like-models/</feedburner:origLink></item>
		<item>
		<title>Web Forms in Ruby on Rails</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/Ffrr61uYFmU/</link>
		<comments>http://railscoach.com/web-forms-in-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 17:56:59 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Views]]></category>
		<category><![CDATA[elements]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[formbuilder]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[form_for]]></category>
		<category><![CDATA[form_tag]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[values]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=131</guid>
		<description><![CDATA[Building web forms in Rails was something that confused me when I was new to the framework. This is probably due to the fact that there are some methods that are a lot alike and there are a couple of ways of instantiating a form that do different things. The first way of building a [...]]]></description>
			<content:encoded><![CDATA[<p>Building web forms in Rails was something that confused me when I was new to the framework. This is probably due to the fact that there are some methods that are a lot alike and there are a couple of ways of instantiating a form that do different things.</p>
<p>The first way of building a form that is probably the most common is by using the ‘form_tag’ helper and the form helpers to build forms. Here’s an example.</p>
<pre>
<%= form_tag ‘/login’ do %>
 <%= label_tag :username %>
 <%= text_field_tag :username %>
 <br />
 <%= label_tag :password %>
 <%= password_field_tag :password %>
 <br />
 <%= submit_tag “Login” %>
<% end %>
</pre>
<p>Pretty straightforward and it builds a standard login form. I’d get confused because there are also helpers that correspond to ‘label_tag’, ‘text_field_tag’, and ‘password_field_tag’ that do something very similar.</p>
<p>Here’s a user signup form that use these similar tags:</p>
<pre>
<%= form_tag ‘/signup’ do %>
 <%= label :user, :username %>
 <%= text_field :user, :username %>
 <br />
 <%= label :user, :password %>
 <%= password_field :user, :password %>
 <br />
 <%= label :user, :password_confirmation %>
 <%= password_field :user, :password_confirmation %>
 <br />
 <%= submit_tag “Sign Up” %>
<% end %>
</pre>
<p>
<p>
You’ll notice that these helpers use two parameters to build the form’s elements. It effectively scopes or namespaces those form parameters. They’ll be named “user[username]”, etc.</p>
<p>If you’ve gotten that much, then ‘form_for’ won’t be too much of stretch. ‘form_for’ takes a model object as a parameter and binds the form to that object. It does the namespacing implicitly, which means that ‘label’ and ‘text_field’, etc don’t need two parameters to name the element. Just one.</p>
<pre>
<%= form_for @user do |f| %>
 <%= f.label :username %>
 <%= f.text_field :username %>
 <br />
 <%= f.label :password %>
 <%= f.password_field :password %>
 <br />
 <%= f.label :password_confirmation %>
 <%= f.password_field :password_confirmation %>
 <br />
 <%= submit_tag “Sign Up” %>
<% end %>
</pre>
<p>
<p>
So, you’ll notice that the ‘form_for’ passes a parameter to the block. That parameter is a FormBuilder that contains the object, scopes the elements, and sets their values.</p>
<p>Finally, go sign up for the Rails course at http://railscoach.com/ruby-on-rails-courses/.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/Ffrr61uYFmU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/web-forms-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC21WebForms_01.mp3" length="10848572" type="audio/mpeg" />
			<itunes:keywords>elements,erb,formbuilder,forms,form_for,form_tag,html,rails,ruby,ruby on rails,values,views</itunes:keywords>
	<itunes:subtitle>Building web forms in Rails was something that confused me when I was new to the framework. This is probably due to the fact that there are some methods that are a lot alike and there are a couple of ways of instantiating a form that do different things.</itunes:subtitle>
		<itunes:summary>Building web forms in Rails was something that confused me when I was new to the framework. This is probably due to the fact that there are some methods that are a lot alike and there are a couple of ways of instantiating a form that do different things.

The first way of building a form that is probably the most common is by using the ‘form_tag’ helper and the form helpers to build forms. Here’s an example.



 
 
 
 
 
 
 



Pretty straightforward and it builds a standard login form. I’d get confused because there are also helpers that correspond to ‘label_tag’, ‘text_field_tag’, and ‘password_field_tag’ that do something very similar.

Here’s a user signup form that use these similar tags:



 
 
 
 
 
 
 
 
 
 



You’ll notice that these helpers use two parameters to build the form’s elements. It effectively scopes or namespaces those form parameters. They’ll be named “user[username]”, etc.

If you’ve gotten that much, then ‘form_for’ won’t be too much of stretch. ‘form_for’ takes a model object as a parameter and binds the form to that object. It does the namespacing implicitly, which means that ‘label’ and ‘text_field’, etc don’t need two parameters to name the element. Just one.



 
 
 
 
 
 
 
 
 
 



So, you’ll notice that the ‘form_for’ passes a parameter to the block. That parameter is a FormBuilder that contains the object, scopes the elements, and sets their values.

Finally, go sign up for the Rails course at http://railscoach.com/ruby-on-rails-courses/.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>7:32</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC21WebForms_01.mp3" fileSize="10848572" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/web-forms-in-ruby-on-rails/</feedburner:origLink></item>
		<item>
		<title>Polymorphic Associations</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/95rdp7HLb54/</link>
		<comments>http://railscoach.com/polymorphic-associations/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 00:32:38 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[Polymorphic Associations]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=94</guid>
		<description><![CDATA[Rails has the concept of Polymorphic associations, which are associations that can be of different data types. For example, let’s say we have a Comment model. A comment in your app can be on a post or a page. Rather than creating a PostComment model and a PageComment model, you can set up your Comment [...]]]></description>
			<content:encoded><![CDATA[<p>Rails has the concept of Polymorphic associations, which are associations that can be of different data types. For example, let’s say we have a Comment model. A comment in your app can be on a post or a page. Rather than creating a PostComment model and a PageComment model, you can set up your Comment model to have a polymorphic association to a Page or a Post.</p>
<p>Generally people call these associations “something-able”. In this case, it would be commentable.</p>
<p>Here’s a quick code sample:</p>
<pre>class Comment &lt; ActiveRecord::Base  belongs_to :commentable, :polymorphic =&gt; true
end

class Page &lt; ActiveRecord::Base  has_many :comments, :as =&gt; :commentable
end

class Post &lt; ActiveRecord::Base  has_many :comments, :as =&gt; :commentable
end</pre>
<p>The only other thing you need to know is the database structure. On the database, you need two columns. A [polymorphic-association-name]_type string column and [polymorphic-association-name]_id integer column. In this case, it would be “commentable_type” and “commentable_id”.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/95rdp7HLb54" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/polymorphic-associations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC20Polymorphic_01.mp3" length="13514706" type="audio/mpeg" />
			<itunes:keywords>Polymorphic Associations,rails,ruby,ruby on rails</itunes:keywords>
	<itunes:subtitle>Rails has the concept of Polymorphic associations, which are associations that can be of different data types. For example, let’s say we have a Comment model. A comment in your app can be on a post or a page.</itunes:subtitle>
		<itunes:summary>Rails has the concept of Polymorphic associations, which are associations that can be of different data types. For example, let’s say we have a Comment model. A comment in your app can be on a post or a page. Rather than creating a PostComment model and a PageComment model, you can set up your Comment model to have a polymorphic association to a Page or a Post.

Generally people call these associations “something-able”. In this case, it would be commentable.

Here’s a quick code sample:
class Comment &lt; ActiveRecord::Base  belongs_to :commentable, :polymorphic =&gt; true
end

class Page &lt; ActiveRecord::Base  has_many :comments, :as =&gt; :commentable
end

class Post &lt; ActiveRecord::Base  has_many :comments, :as =&gt; :commentable
end
The only other thing you need to know is the database structure. On the database, you need two columns. A [polymorphic-association-name]_type string column and [polymorphic-association-name]_id integer column. In this case, it would be “commentable_type” and “commentable_id”.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>9:23</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC20Polymorphic_01.mp3" fileSize="13514706" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/polymorphic-associations/</feedburner:origLink></item>
		<item>
		<title>Model Associations</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/3FXoUl9-qhg/</link>
		<comments>http://railscoach.com/model-associations/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 15:17:06 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[associations]]></category>
		<category><![CDATA[belongs to]]></category>
		<category><![CDATA[has and belongs to many]]></category>
		<category><![CDATA[has many]]></category>
		<category><![CDATA[many to many]]></category>
		<category><![CDATA[one to many]]></category>
		<category><![CDATA[one to one]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=91</guid>
		<description><![CDATA[ActiveRecord models are based upon tables in relational databases. This, of course, means that they can be relational. Models can associate in three main ways: one to many, one to one, and many to many. One to many is usually achieved by calling has_many on the model representing the “one” to state that it “has [...]]]></description>
			<content:encoded><![CDATA[<p>ActiveRecord models are based upon tables in relational databases. This, of course, means that they can be relational. Models can associate in three main ways: one to many, one to one, and many to many.</p>
<p>One to many is usually achieved by calling <em>has_many</em> on the model representing the “one” to state that it “has many” of its counterparts. The model that represents the “many” calls<br />
<em>belongs_to</em> . Here’s an example:</p>
<pre>class User &lt; ActiveRecord::Base
 has_many :posts
end

class Post &lt; ActiveRecord::Base
 belongs_to :user
end</pre>
<p>In addition, the model that represents the “many” needs a reference column or foreign key for the “one”. In this case, the posts table would have a user_id column.</p>
<p>One to one works the same way one to many works except it uses <em>has_one</em> instead of <em>has_many</em>.</p>
<p>Many to many is implemented in one of two different ways. The first&#8211;and generally default&#8211;way of doing this is <em>has_and_belongs_to_many</em>. As you can imagine, this is used just like <em>has_many</em> or <em>belongs_to</em> except you call it in both models.</p>
<pre>class Tag &lt; ActiveRecord::Base
 has_and_belongs_to_many :posts
end

class Post &lt; ActiveRecord::Base
 has_and_belongs_to_many :tags
end</pre>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/3FXoUl9-qhg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/model-associations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC19ModelAssociations_01.mp3" length="14893158" type="audio/mpeg" />
			<itunes:keywords>activerecord,associations,belongs to,has and belongs to many,has many,many to many,one to many,one to one</itunes:keywords>
	<itunes:subtitle>ActiveRecord models are based upon tables in relational databases. This, of course, means that they can be relational. Models can associate in three main ways: one to many, one to one, and many to many. - </itunes:subtitle>
		<itunes:summary>ActiveRecord models are based upon tables in relational databases. This, of course, means that they can be relational. Models can associate in three main ways: one to many, one to one, and many to many.

One to many is usually achieved by calling has_many on the model representing the “one” to state that it “has many” of its counterparts. The model that represents the “many” calls
belongs_to . Here’s an example:
class User &lt; ActiveRecord::Base
 has_many :posts
end

class Post &lt; ActiveRecord::Base
 belongs_to :user
end
In addition, the model that represents the “many” needs a reference column or foreign key for the “one”. In this case, the posts table would have a user_id column.

One to one works the same way one to many works except it uses has_one instead of has_many.

Many to many is implemented in one of two different ways. The first--and generally default--way of doing this is has_and_belongs_to_many. As you can imagine, this is used just like has_many or belongs_to except you call it in both models.
class Tag &lt; ActiveRecord::Base
 has_and_belongs_to_many :posts
end

class Post &lt; ActiveRecord::Base
 has_and_belongs_to_many :tags
end</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>10:20</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC19ModelAssociations_01.mp3" fileSize="14893158" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/model-associations/</feedburner:origLink></item>
		<item>
		<title>Rails Controllers: Before, After, and Around Filters</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/p8zNC2RIpe0/</link>
		<comments>http://railscoach.com/rails-controllers-before-after-and-around-filters/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 17:31:25 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Controllers]]></category>
		<category><![CDATA[after filter]]></category>
		<category><![CDATA[around filter]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[Authorization]]></category>
		<category><![CDATA[before filter]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[exceptions]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[flow]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[preloading]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[request]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[yield]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=86</guid>
		<description><![CDATA[In your Rails controllers you have filters you can place on incoming requests, outgoing responses, or wrap around your actions. Before filters are run on requests before the request gets to the controller’s action. It can return a response itself and completely bypass the action. The most common use of before filters is validating a [...]]]></description>
			<content:encoded><![CDATA[<p>In your Rails controllers you have filters you can place on incoming requests, outgoing responses, or wrap around your actions.</p>
<p>Before filters are run on requests before the request gets to the controller’s action. It can return a response itself and completely bypass the action.</p>
<p>The most common use of before filters is validating a user’s authentication before granting them access to the action designated to handle their request. I’ve also seen them used to load a resource from the database, check permissions on a resource, or manage redirects under other circumstances.</p>
<p>After filters are run after the action completes. It can modify the response. Most of the time if something is done in an after filter, it can be done in the action itself, but if there is some logic to be run after running any of a set of actions, then an after filter is a good place to do it.</p>
<p>Generally, I’ve seen after and around filters used for logging.</p>
<p>Around filters may have logic before and after the action being run. It simply yields to the action in whatever place is necessary. Note that it doesn’t need to yield to the action and may run without doing so like a before filter.</p>
<p>You can use around filters for exception handling, setup and teardown, and a myriad of other cases.</p>
<p><object width="480" height="390" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/4rhl4DqT8AA?version=3&amp;hl=en_US&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed width="480" height="390" type="application/x-shockwave-flash" src="http://www.youtube.com/v/4rhl4DqT8AA?version=3&amp;hl=en_US&amp;rel=0" allowFullScreen="true" allowscriptaccess="always" allowfullscreen="true" /></object></p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/p8zNC2RIpe0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/rails-controllers-before-after-and-around-filters/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC18Filters_01.mp3" length="10451410" type="audio/mpeg" />
			<itunes:keywords>after filter,around filter,authentication,Authorization,before filter,controller,exceptions,filter,flow,logging,preloading,rails</itunes:keywords>
	<itunes:subtitle>In your Rails controllers you have filters you can place on incoming requests, outgoing responses, or wrap around your actions. - Before filters are run on requests before the request gets to the controller’s action.</itunes:subtitle>
		<itunes:summary>In your Rails controllers you have filters you can place on incoming requests, outgoing responses, or wrap around your actions.

Before filters are run on requests before the request gets to the controller’s action. It can return a response itself and completely bypass the action.

The most common use of before filters is validating a user’s authentication before granting them access to the action designated to handle their request. I’ve also seen them used to load a resource from the database, check permissions on a resource, or manage redirects under other circumstances.

After filters are run after the action completes. It can modify the response. Most of the time if something is done in an after filter, it can be done in the action itself, but if there is some logic to be run after running any of a set of actions, then an after filter is a good place to do it.

Generally, I’ve seen after and around filters used for logging.

Around filters may have logic before and after the action being run. It simply yields to the action in whatever place is necessary. Note that it doesn’t need to yield to the action and may run without doing so like a before filter.

You can use around filters for exception handling, setup and teardown, and a myriad of other cases.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>7:15</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC18Filters_01.mp3" fileSize="10451410" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/rails-controllers-before-after-and-around-filters/</feedburner:origLink></item>
		<item>
		<title>ActiveRecord Callbacks</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/zg-LIbIEvU8/</link>
		<comments>http://railscoach.com/activerecord-callbacks/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 17:46:10 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[after]]></category>
		<category><![CDATA[before]]></category>
		<category><![CDATA[callbacks]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[models]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rollback]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=82</guid>
		<description><![CDATA[You can get a full list of the ActiveRecord callbacks here. Callbacks are a handy way of insuring specific behaviors on your models as well as managing the events that follow the callbacks. For example, a before_destroy callback can be called to destroy associated objects. (This is best done on the association with :dependent =&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>You can get a full list of the ActiveRecord callbacks <a href="http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html">here</a>.</p>
<p>Callbacks are a handy way of insuring specific behaviors on your models as well as managing the events that follow the callbacks.</p>
<p>For example, a before_destroy callback can be called to destroy associated objects. (This is best done on the association with :dependent =&gt; :destroy, but it makes sense here too.)</p>
<p>You can also stop the destroy process if you have dependent objects you can’t destroy by returning false.</p>
<p>I’ve used ActiveRecord Callbacks to:</p>
<ul>
<li>Set default values</li>
<li>Format specific fields (like phone numbers)</li>
<li>Send emails when an object is updated or deleted</li>
<li>Create child objects from comma delimited lists in a string</li>
<li>Change an object’s state</li>
</ul>
<p><object width="480" height="390" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/vpEVo_-B9s0?version=3&amp;hl=en_US&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed width="480" height="390" type="application/x-shockwave-flash" src="http://www.youtube.com/v/vpEVo_-B9s0?version=3&amp;hl=en_US&amp;rel=0" allowFullScreen="true" allowscriptaccess="always" allowfullscreen="true" /></object></p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/zg-LIbIEvU8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/activerecord-callbacks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC17ActiveRecordCallbacks_01.mp3" length="11855180" type="audio/mpeg" />
			<itunes:keywords>activerecord,after,before,callbacks,examples,models,rails,rollback,ruby,ruby on rails,workflow</itunes:keywords>
	<itunes:subtitle>You can get a full list of the ActiveRecord callbacks here. - Callbacks are a handy way of insuring specific behaviors on your models as well as managing the events that follow the callbacks. - For example,</itunes:subtitle>
		<itunes:summary>You can get a full list of the ActiveRecord callbacks here.

Callbacks are a handy way of insuring specific behaviors on your models as well as managing the events that follow the callbacks.

For example, a before_destroy callback can be called to destroy associated objects. (This is best done on the association with :dependent =&gt; :destroy, but it makes sense here too.)

You can also stop the destroy process if you have dependent objects you can’t destroy by returning false.

I’ve used ActiveRecord Callbacks to:

	Set default values
	Format specific fields (like phone numbers)
	Send emails when an object is updated or deleted
	Create child objects from comma delimited lists in a string
	Change an object’s state</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>8:14</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC17ActiveRecordCallbacks_01.mp3" fileSize="11855180" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/activerecord-callbacks/</feedburner:origLink></item>
		<item>
		<title>The DRY Principle</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/lPCdo7g91WY/</link>
		<comments>http://railscoach.com/the-dry-principle/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 14:36:40 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Extending Rails]]></category>
		<category><![CDATA[Don’t Repeat Yourself]]></category>
		<category><![CDATA[DRY]]></category>
		<category><![CDATA[extending]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[Pragmatic Programmer]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=79</guid>
		<description><![CDATA[According to The Pragmatic Programmer by Andy Hunt and Dave Thomas, &#8220;Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.&#8221; Last week I talked about extending your Ruby on Rails application. This is because in many cases in order to avoid repeating your logic across multiple classes (models or controllers) [...]]]></description>
			<content:encoded><![CDATA[<p id="internal-source-marker_0.25973630883475695" dir="ltr">According to <a href="http://www.amazon.com/gp/product/020161622X/ref=as_li_ss_tl?ie=UTF8&amp;tag=chamaxwoo-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399369&amp;creativeASIN=020161622X">The Pragmatic Programmer</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=&amp;l=as2&amp;o=1&amp;a=020161622X&amp;camp=217145&amp;creative=399369" border="0" alt="" width="1" height="1" /> by <a href="http://teachmetocode.com/podcast/tmtc-41-andy-hunt/">Andy Hunt</a> and <a href="http://teachmetocode.com/podcast/rc-17-interview-with-dave-thomas-from-the-pragmatic-programmers-part-1/">Dave Thomas</a>, &#8220;Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.&#8221;</p>
<p>Last week I talked about extending your Ruby on Rails application. This is because in many cases in order to avoid repeating your logic across multiple classes (models or controllers) you need another place to put your functionality.</p>
<p>Mix-in modules, plugins, and single table inheritance all allow you to codify your knowledge into a single place depending on what you’re working with.</p>
<p>The DRY principle is more than just a way to avoid having to update multiple files when something changes. Rather, it’s a way of assuring yourself that things are done in a consistent manner.</p>
<p>It also helps you when you’re trying to find something in your application because there’s only one place where it can be found.</p>
<p><object width="480" height="390"><param name="movie" value="http://www.youtube.com/v/6n3JyUs1gUc?version=3&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/6n3JyUs1gUc?version=3&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" width="480" height="390" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/lPCdo7g91WY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/the-dry-principle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC16DRYPrinciple_01.mp3" length="11122760" type="audio/mpeg" />
			<itunes:keywords>Don’t Repeat Yourself,DRY,extending,extensions,Pragmatic Programmer,rails,ruby,ruby on rails</itunes:keywords>
	<itunes:subtitle>According to The Pragmatic Programmer by Andy Hunt and Dave Thomas, "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." Last week I talked about extending your Ruby on Rails application.</itunes:subtitle>
		<itunes:summary>According to The Pragmatic Programmer by Andy Hunt and Dave Thomas, "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system."
Last week I talked about extending your Ruby on Rails application. This is because in many cases in order to avoid repeating your logic across multiple classes (models or controllers) you need another place to put your functionality.

Mix-in modules, plugins, and single table inheritance all allow you to codify your knowledge into a single place depending on what you’re working with.

The DRY principle is more than just a way to avoid having to update multiple files when something changes. Rather, it’s a way of assuring yourself that things are done in a consistent manner.

It also helps you when you’re trying to find something in your application because there’s only one place where it can be found.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>7:43</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC16DRYPrinciple_01.mp3" fileSize="11122760" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/the-dry-principle/</feedburner:origLink></item>
		<item>
		<title>Extending Ruby on Rails</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/7AoDn49SjV0/</link>
		<comments>http://railscoach.com/extending-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 16:02:42 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Extending Rails]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[extending]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[junk drawer]]></category>
		<category><![CDATA[lib]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=75</guid>
		<description><![CDATA[I’m going to be talking about the DRY principle next week. However, before I jump into that, I need to discuss how to extend Ruby on Rails so you know where you can put functionality to keep your application DRY. There are a couple of standard places people put code that isn’t a Model, View, [...]]]></description>
			<content:encoded><![CDATA[<p>I’m going to be talking about the DRY principle next week. However, before I jump into that, I need to discuss how to extend Ruby on Rails so you know where you can put functionality to keep your application DRY.</p>
<p>There are a couple of standard places people put code that isn’t a Model, View, Controller, or Helper:</p>
<ul>
<li>The ‘lib’ folder &#8211; This is sort of a “junk drawer” for your application. In Rails 3 your application does not load these files on its own. You can make it autoload by following the directions I found on <a href="http://stackoverflow.com/questions/3356742/best-way-to-load-module-class-from-lib-folder-in-rails-3">StackOverflow</a>.</li>
<li><a href="http%3A%2F%2Fguides.rubyonrails.org%2Fplugins.html">Rails Plugins</a> &#8211; Rails Plugins are autoloaded by your Rails applications and can contain extensions to Models, Views, Controllers, Helpers, and to the app as a whole through Engines.</li>
<li><a href="http://rubygems.org">Ruby Gems </a>- Gems can do pretty much anything Plugins can do except they are not included in your application’s source. They are pulled in through <a href="http://gembundler.com/">Bundler</a>.</li>
<li>You can also add modules and classes to files within the app directory.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/7AoDn49SjV0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/extending-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC15ExtendingRails_01.mp3" length="14235858" type="audio/mpeg" />
			<itunes:keywords>classes,extending,extensions,gems,junk drawer,lib,modules,plugins,rails,ruby,ruby on rails</itunes:keywords>
	<itunes:subtitle>I’m going to be talking about the DRY principle next week. However, before I jump into that, I need to discuss how to extend Ruby on Rails so you know where you can put functionality to keep your application DRY. - </itunes:subtitle>
		<itunes:summary>I’m going to be talking about the DRY principle next week. However, before I jump into that, I need to discuss how to extend Ruby on Rails so you know where you can put functionality to keep your application DRY.

There are a couple of standard places people put code that isn’t a Model, View, Controller, or Helper:

	The ‘lib’ folder - This is sort of a “junk drawer” for your application. In Rails 3 your application does not load these files on its own. You can make it autoload by following the directions I found on StackOverflow.
	Rails Plugins - Rails Plugins are autoloaded by your Rails applications and can contain extensions to Models, Views, Controllers, Helpers, and to the app as a whole through Engines.
	Ruby Gems - Gems can do pretty much anything Plugins can do except they are not included in your application’s source. They are pulled in through Bundler.
	You can also add modules and classes to files within the app directory.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>9:53</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC15ExtendingRails_01.mp3" fileSize="14235858" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/extending-ruby-on-rails/</feedburner:origLink></item>
		<item>
		<title>Rails’ Component Libraries</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/mwE6sa1EuQ8/</link>
		<comments>http://railscoach.com/rails%e2%80%99-component-libraries/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 00:02:37 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Rails Concepts]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=70</guid>
		<description><![CDATA[Rails is made up of several components that all have specific jobs in making your Rails application work. Here’s a quick list of what they are and what they do. ActionMailer &#8211; The basis for mailers. This is the library that allows you to format and send emails from your rails application ActionPack &#8211; The [...]]]></description>
			<content:encoded><![CDATA[<p>Rails is made up of several components that all have specific jobs in making your Rails application work. Here’s a quick list of what they are and what they do.</p>
<ul>
<li> ActionMailer &#8211; The basis for mailers. This is the library that allows you to format and send emails from your rails application</li>
<li> ActionPack &#8211; The components that parse, delegate, and render responses for requests.
<ul>
<li> ActionDispatch &#8211; Parses HTTP requests and sends the requests to controllers.</li>
<li> ActionController &#8211; Basis for Controllers -Takes requests and request parameters and gathers data to render a response.</li>
<li> ActionView &#8211; Basis for Views. Determines which template to use and builds the response to the HTTP request from the templates based on data provided by the Controller.</li>
</ul>
</li>
<li> ActiveModel &#8211; Defines an interface on non-ActiveRecord classes that helps the behave like ActiveRecord models.</li>
<li> ActiveRecord &#8211; Basis for Models. Manages the connection between the Rails application and a SQL database. Provides means of querying database to manage and find records.</li>
<li> ActiveResource &#8211; Allows the developer to access network REST resources in a simple way.</li>
<li> ActiveSupport &#8211; A collection of extensions to the Ruby programming language that can be used in your Ruby on Rails application.</li>
</ul>
<p>You can read in more detail what these libraries are about and what they do on the <a href="http://github.com/rails/rails">Ruby on Rails github page</a>.</p>
<p><object width="640" height="390"><param name="movie" value="http://www.youtube.com/v/Krawi2LOj3E?version=3&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Krawi2LOj3E?version=3&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" width="640" height="390" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/mwE6sa1EuQ8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/rails%e2%80%99-component-libraries/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC14RailsComponentLibraries_01.WAVedited.mp3" length="14269662" type="audio/mpeg" />
		<itunes:subtitle>Rails is made up of several components that all have specific jobs in making your Rails application work. Here’s a quick list of what they are and what they do.   ActionMailer - The basis for mailers. This is the library that allows you to format an...</itunes:subtitle>
		<itunes:summary>Rails is made up of several components that all have specific jobs in making your Rails application work. Here’s a quick list of what they are and what they do.

	 ActionMailer - The basis for mailers. This is the library that allows you to format and send emails from your rails application
	 ActionPack - The components that parse, delegate, and render responses for requests.

	 ActionDispatch - Parses HTTP requests and sends the requests to controllers.
	 ActionController - Basis for Controllers -Takes requests and request parameters and gathers data to render a response.
	 ActionView - Basis for Views. Determines which template to use and builds the response to the HTTP request from the templates based on data provided by the Controller.


	 ActiveModel - Defines an interface on non-ActiveRecord classes that helps the behave like ActiveRecord models.
	 ActiveRecord - Basis for Models. Manages the connection between the Rails application and a SQL database. Provides means of querying database to manage and find records.
	 ActiveResource - Allows the developer to access network REST resources in a simple way.
	 ActiveSupport - A collection of extensions to the Ruby programming language that can be used in your Ruby on Rails application.

You can read in more detail what these libraries are about and what they do on the Ruby on Rails github page.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>9:54</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC14RailsComponentLibraries_01.WAVedited.mp3" fileSize="14269662" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/rails%e2%80%99-component-libraries/</feedburner:origLink></item>
		<item>
		<title>Debugging</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/9YBcCxBMfuc/</link>
		<comments>http://railscoach.com/debugging/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 01:57:54 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Debugging]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=67</guid>
		<description><![CDATA[We talked quite a bit today about debugging tools in the Ruby Rogues podcast. I recorded this before that episode. Here&#8217;s a brief introduction on how to use debuggers to find problems in your Rails code. The basic idea is that your set a breakpoint in your application, which causes the application to stop processing [...]]]></description>
			<content:encoded><![CDATA[<p>We talked quite a bit today about debugging tools in the Ruby Rogues podcast. I recorded this before that episode. Here&#8217;s a brief introduction on how to use debuggers to find problems in your Rails code.</p>
<p>The basic idea is that your set a breakpoint in your application, which causes the application to stop processing and allow you to access the application&#8217;s state and step through the methods being called in order to find the cause of your problem.</p>
<p>With the Ruby Debug library, all you need to do is require &#8216;ruby-debug&#8217; and call &#8216;debugger&#8217; where you want the application to stop.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/9YBcCxBMfuc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/debugging/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC13Debugging.mp3" length="10035960" type="audio/mpeg" />
		<itunes:subtitle>We talked quite a bit today about debugging tools in the Ruby Rogues podcast. I recorded this before that episode. Here's a brief introduction on how to use debuggers to find problems in your Rails code. - </itunes:subtitle>
		<itunes:summary>We talked quite a bit today about debugging tools in the Ruby Rogues podcast. I recorded this before that episode. Here's a brief introduction on how to use debuggers to find problems in your Rails code.

The basic idea is that your set a breakpoint in your application, which causes the application to stop processing and allow you to access the application's state and step through the methods being called in order to find the cause of your problem.

With the Ruby Debug library, all you need to do is require 'ruby-debug' and call 'debugger' where you want the application to stop.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>8:21</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC13Debugging.mp3" fileSize="10035960" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/debugging/</feedburner:origLink></item>
		<item>
		<title>Convention over Configuration</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/bViomDTJgBg/</link>
		<comments>http://railscoach.com/convention-over-configuration/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 14:42:37 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Rails Concepts]]></category>
		<category><![CDATA[convention over configuration]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[file name]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[naming conventions]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=64</guid>
		<description><![CDATA[The idea behind convention over configuration is that rather than having several or one large configuration file to set up the framework for you to use, Rails uses conventions to determine how things should work without configuration. In many cases in Rails, there are ways to override the default convention, but most people stick to [...]]]></description>
			<content:encoded><![CDATA[<p>The idea behind convention over configuration is that rather than having several or one large configuration file to set up the framework for you to use, Rails uses conventions to determine how things should work without configuration. In many cases in Rails, there are ways to override the default convention, but most people stick to the conventions.</p>
<p>The conventions make it easy to set up and get started with Ruby on Rails. They also make it extremely easy for a person unfamiliar with your Rails project to step in and figure out what is going on.</p>
<p>Some of the conventions in Rails are the following:</p>
<p>A model&#8217;s class is the camel cased singular version of its table name. The file name is the underscore cased version of the class name. The table name is the underscore cased pluralized model name. So, for example, the User model will be /app/models/user.rb and correspond to the &#8220;users&#8221; table in the database.</p>
<p>Similar conventions apply to controllers, helpers, views, and tests.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/bViomDTJgBg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/convention-over-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC12ConventionOverConfiguration.mp3" length="13869022" type="audio/mpeg" />
			<itunes:keywords>convention over configuration,database,file name,model,naming conventions</itunes:keywords>
	<itunes:subtitle>The idea behind convention over configuration is that rather than having several or one large configuration file to set up the framework for you to use, Rails uses conventions to determine how things should work without configuration.</itunes:subtitle>
		<itunes:summary>The idea behind convention over configuration is that rather than having several or one large configuration file to set up the framework for you to use, Rails uses conventions to determine how things should work without configuration. In many cases in Rails, there are ways to override the default convention, but most people stick to the conventions.

The conventions make it easy to set up and get started with Ruby on Rails. They also make it extremely easy for a person unfamiliar with your Rails project to step in and figure out what is going on.

Some of the conventions in Rails are the following:

A model's class is the camel cased singular version of its table name. The file name is the underscore cased version of the class name. The table name is the underscore cased pluralized model name. So, for example, the User model will be /app/models/user.rb and correspond to the "users" table in the database.

Similar conventions apply to controllers, helpers, views, and tests.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>9:38</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC12ConventionOverConfiguration.mp3" fileSize="13869022" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/convention-over-configuration/</feedburner:origLink></item>
		<item>
		<title>Ruby on Rails Routing</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/CQpLvTUUCTw/</link>
		<comments>http://railscoach.com/ruby-on-rails-routing/#comments</comments>
		<pubDate>Fri, 27 May 2011 05:47:35 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Routing]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[member]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[restful resources]]></category>
		<category><![CDATA[routes]]></category>
		<category><![CDATA[routing]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=57</guid>
		<description><![CDATA[Ruby on Rails routing can be a little confusing. Here are some of the high points. The root path is specified by the &#8216;root&#8217; method. It matches the &#8216;/&#8217; path and behaves like &#8216;match&#8217;. The &#8216;match&#8217; method will match the requested path to the string passed to match and route to the controller and action [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby on Rails routing can be a little confusing. Here are some of the high points.</p>
<p>The root path is specified by the &#8216;root&#8217; method. It matches the &#8216;/&#8217; path and behaves like &#8216;match&#8217;.</p>
<p>The &#8216;match&#8217; method will match the requested path to the string passed to match and route to the controller and action specified. </p>
<pre class="brush: ruby">
# Sends requests to /users/list to PeopleController#index
match "users/list", :to => "people#index"
</pre>
<p>You can also extract variables from the path.</p>
<pre class="brush: ruby">
# Matches /user/1/edit and passes '1' in params[:id]
match "users/:id/edit", :to => "users#edit"
</pre>
<p>You can specify which HTTP request methods are valid for a route.</p>
<pre class="brush: ruby">
get "users/index"

match "users/index", :to => "users#index", :via => :get
</pre>
<p>You can also name a route and use the related helper methods.</p>
<pre class="brush: ruby">
match "users/index", :to => "users#index", :as => "user_index"

#In some controller or view
user_index_path
# => "/users/index"

user_index_url
# => "http://localhost:3000/users/index"
</pre>
<p>You can also create RESTful resources around a model. See the <a href="http://guides.rubyonrails.org/routing.html">Rails Guides</a> for details.</p>
<pre class="brush: ruby">
resource :user
</pre>
<p>Finally, you can add to a RESTful resource when needed.</p>
<pre class="brush: ruby">
# allows you to post to '/users/1/make_admin' and get '/users/show_admins'
resource :user do
  post :make_admin, :on => :member
  get :show_admins, :on => :collection
end
</pre>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/CQpLvTUUCTw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/ruby-on-rails-routing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC11Routing.mp3" length="16558944" type="audio/mpeg" />
			<itunes:keywords>collection,helpers,member,rails,rest,restful resources,routes,routing,ruby,ruby on rails</itunes:keywords>
	<itunes:subtitle>Ruby on Rails routing can be a little confusing. Here are some of the high points. - The root path is specified by the 'root' method. It matches the '/' path and behaves like 'match'. - The 'match' method will match the requested path to the string p...</itunes:subtitle>
		<itunes:summary>Ruby on Rails routing can be a little confusing. Here are some of the high points.

The root path is specified by the 'root' method. It matches the '/' path and behaves like 'match'.

The 'match' method will match the requested path to the string passed to match and route to the controller and action specified. 


# Sends requests to /users/list to PeopleController#index
match "users/list", :to =&gt; "people#index"


You can also extract variables from the path.


# Matches /user/1/edit and passes '1' in params[:id]
match "users/:id/edit", :to =&gt; "users#edit"


You can specify which HTTP request methods are valid for a route.


get "users/index"

match "users/index", :to =&gt; "users#index", :via =&gt; :get


You can also name a route and use the related helper methods.


match "users/index", :to =&gt; "users#index", :as =&gt; "user_index"

#In some controller or view
user_index_path
# =&gt; "/users/index"

user_index_url
# =&gt; "http://localhost:3000/users/index"


You can also create RESTful resources around a model. See the Rails Guides for details.

resource :user


Finally, you can add to a RESTful resource when needed.


# allows you to post to '/users/1/make_admin' and get '/users/show_admins'
resource :user do
  post :make_admin, :on =&gt; :member
  get :show_admins, :on =&gt; :collection
end</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>11:30</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC11Routing.mp3" fileSize="16558944" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/ruby-on-rails-routing/</feedburner:origLink></item>
		<item>
		<title>Rails Engines</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/CaXr2rYZtWE/</link>
		<comments>http://railscoach.com/rails-engines/#comments</comments>
		<pubDate>Fri, 20 May 2011 19:50:45 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Extending Rails]]></category>
		<category><![CDATA[3.1]]></category>
		<category><![CDATA[assets]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[engines]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[generators]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rake tasks]]></category>
		<category><![CDATA[routes]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=53</guid>
		<description><![CDATA[Rails Engines are a terrific way of mounting on Ruby on Rails application into another. A Rails Engine is basically a Rails application with an Engine class installed. The main application&#8212;the application your engine is mounted into&#8212;uses the generators, rake tasks, and routes from engines automatically. As of Rails 3.1, rake tasks are provided to [...]]]></description>
			<content:encoded><![CDATA[<p>Rails Engines are a terrific way of mounting on Ruby on Rails application into another.</p>
<p>A Rails Engine is basically a Rails application with an Engine class installed. The main application&mdash;the application your engine is mounted into&mdash;uses the generators, rake tasks, and routes from engines automatically. As of Rails 3.1, rake tasks are provided to move migrations and assets into the main application.</p>
<p>You can use Engines to add features to your current application or you can use it to provide an entire section of your website.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/CaXr2rYZtWE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/rails-engines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC10RailsEngines.mp3" length="14309726" type="audio/mpeg" />
			<itunes:keywords>3.1,assets,embed,engines,extend,generators,mount,rails,rake tasks,routes,ruby</itunes:keywords>
	<itunes:subtitle>Rails Engines are a terrific way of mounting on Ruby on Rails application into another. - A Rails Engine is basically a Rails application with an Engine class installed. The main application—the application your engine is mounted into—uses the generat...</itunes:subtitle>
		<itunes:summary>Rails Engines are a terrific way of mounting on Ruby on Rails application into another.

A Rails Engine is basically a Rails application with an Engine class installed. The main application—the application your engine is mounted into—uses the generators, rake tasks, and routes from engines automatically. As of Rails 3.1, rake tasks are provided to move migrations and assets into the main application.

You can use Engines to add features to your current application or you can use it to provide an entire section of your website.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>9:56</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC10RailsEngines.mp3" fileSize="14309726" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/rails-engines/</feedburner:origLink></item>
		<item>
		<title>009 RC RubyGems and Bundler</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/hG-GRf9sD94/</link>
		<comments>http://railscoach.com/009-rc-rubygems-and-bundler/#comments</comments>
		<pubDate>Thu, 12 May 2011 20:42:36 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Extending Rails]]></category>
		<category><![CDATA[bundle install]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[gemfile]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[generators]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[setup]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=51</guid>
		<description><![CDATA[Ruby has a package manager for its libraries or gems. It should be a concept familiar with other package managers like apt, yum, or yast. Gems are libraries for Ruby. Many gems are built to extend Ruby on Rails and are a great way to add functionality to your application. You can see available gems [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby has a package manager for its libraries or gems. It should be a concept familiar with other package managers like apt, yum, or yast. </p>
<p>Gems are libraries for Ruby. Many gems are built to extend Ruby on Rails and are a great way to add functionality to your application. You can see available gems at <a href="http://rubygems.org">RubyGems.org</a>. In order to install Rails, you typically need Rubygems installed via a &#8220;gem install rails&#8221;. To get a pre-release version of Rails, you can run &#8220;gem install rails &#8211;pre&#8221;.</p>
<p>Gems for use in your Rails application are included in your Gemfile. Once you&#8217;ve specified the gems, run &#8220;bundle&#8221; or &#8220;bundle install&#8221; to get the gems you need. You can set up a test group to include testing and debugging libraries and exclude them in production environments.</p>
<p>Bundler handles dependency problems by evaluating dependencies and then chooses the libraries that meet all dependencies.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/hG-GRf9sD94" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/009-rc-rubygems-and-bundler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC9RubyGemsNBundler.mp3" length="15979970" type="audio/mpeg" />
			<itunes:keywords>bundle install,bundler,extensions,gemfile,gems,generators,install,libraries,rails,ruby on rails,setup</itunes:keywords>
	<itunes:subtitle>Ruby has a package manager for its libraries or gems. It should be a concept familiar with other package managers like apt, yum, or yast.  - Gems are libraries for Ruby. Many gems are built to extend Ruby on Rails and are a great way to add functional...</itunes:subtitle>
		<itunes:summary>Ruby has a package manager for its libraries or gems. It should be a concept familiar with other package managers like apt, yum, or yast. 

Gems are libraries for Ruby. Many gems are built to extend Ruby on Rails and are a great way to add functionality to your application. You can see available gems at RubyGems.org. In order to install Rails, you typically need Rubygems installed via a "gem install rails". To get a pre-release version of Rails, you can run "gem install rails --pre".

Gems for use in your Rails application are included in your Gemfile. Once you've specified the gems, run "bundle" or "bundle install" to get the gems you need. You can set up a test group to include testing and debugging libraries and exclude them in production environments.

Bundler handles dependency problems by evaluating dependencies and then chooses the libraries that meet all dependencies.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>13:19</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC9RubyGemsNBundler.mp3" fileSize="15979970" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/009-rc-rubygems-and-bundler/</feedburner:origLink></item>
		<item>
		<title>008 RC ActiveRecord Migration Gotchas</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/cJZpkSnxmwM/</link>
		<comments>http://railscoach.com/008-rc-activerecord-migration-gotchas/#comments</comments>
		<pubDate>Sat, 07 May 2011 21:08:15 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[foreign ids]]></category>
		<category><![CDATA[has_many]]></category>
		<category><![CDATA[id]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[meta data]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=47</guid>
		<description><![CDATA[Rails Migrations are generally pretty straightforward, but there are a few things that people do that wind up giving them headaches later on. First, don&#8217;t change migrations once they&#8217;ve been committed or deployed. This causes problems because ActiveRecord tracks migrations that have already been run. So, editing a migration that&#8217;s already been run will result [...]]]></description>
			<content:encoded><![CDATA[<p>Rails Migrations are generally pretty straightforward, but there are a few things that people do that wind up giving them headaches later on. </p>
<p>First, don&#8217;t change migrations once they&#8217;ve been committed or deployed. This causes problems because ActiveRecord tracks migrations that have already been run. So, editing a migration that&#8217;s already been run will result in your changes not being made.</p>
<p>Second, use Rails&#8217; built in migration and model generators. It generates the id number in the front of the migration from a timestamp which minimizes that possibility of having a collision on the migration&#8217;s identifier.</p>
<p>Third, create mapping tables in your migrations so your connections work. When you do these migrations, make sure you have &#8220;:id => false&#8221; on your &#8220;create_table&#8221; call. </p>
<p>When creating mapping tables, eliminate the meta data on the mapping unless you&#8217;re using a &#8220;has_many :through =>&#8221; relationship. Adding meta fields to mapping tables will be deprecated in Rails 3.1.</p>
<p>Fourth, add indexes to all foreign id&#8217;s. Those are the &#8220;_id&#8221; columns in your tables. I&#8217;ve used the <a href="https://github.com/eladmeidar/rails_indexes">rails_indexes</a> plugin for this.</p>
<p>Fifth, don&#8217;t reference Models in your migrations. If your Model implementation or attribute sets change, your migrations may no longer work. Instead, call &#8220;execute&#8221; with your SQL queries to update and save data in the database in your migrations.</p>
<p>Finally, go check out the <a href="http://rubyrogues.com">Ruby Rogues podcast</a>! You can also get my interview with Tom Preston-Werner from Github <a href="http://teachmetocode.com/podcast/56-tmtc-tom-preston-werner-github-co-founder/">here</a>.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/cJZpkSnxmwM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/008-rc-activerecord-migration-gotchas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC8Migrations.mp3" length="17290114" type="audio/mpeg" />
			<itunes:keywords>database,foreign ids,has_many,id,index,meta data,migration,ruby on rails,SQL</itunes:keywords>
	<itunes:subtitle>Rails Migrations are generally pretty straightforward, but there are a few things that people do that wind up giving them headaches later on.  - First, don't change migrations once they've been committed or deployed.</itunes:subtitle>
		<itunes:summary>Rails Migrations are generally pretty straightforward, but there are a few things that people do that wind up giving them headaches later on. 

First, don't change migrations once they've been committed or deployed. This causes problems because ActiveRecord tracks migrations that have already been run. So, editing a migration that's already been run will result in your changes not being made.

Second, use Rails' built in migration and model generators. It generates the id number in the front of the migration from a timestamp which minimizes that possibility of having a collision on the migration's identifier.

Third, create mapping tables in your migrations so your connections work. When you do these migrations, make sure you have ":id =&gt; false" on your "create_table" call. 

When creating mapping tables, eliminate the meta data on the mapping unless you're using a "has_many :through =&gt;" relationship. Adding meta fields to mapping tables will be deprecated in Rails 3.1.

Fourth, add indexes to all foreign id's. Those are the "_id" columns in your tables. I've used the rails_indexes plugin for this.

Fifth, don't reference Models in your migrations. If your Model implementation or attribute sets change, your migrations may no longer work. Instead, call "execute" with your SQL queries to update and save data in the database in your migrations.

Finally, go check out the Ruby Rogues podcast! You can also get my interview with Tom Preston-Werner from Github here.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>14:24</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC8Migrations.mp3" fileSize="17290114" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/008-rc-activerecord-migration-gotchas/</feedburner:origLink></item>
		<item>
		<title>007 RC Rails Authorization Basics</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/Fo_2H_jyGYs/</link>
		<comments>http://railscoach.com/007-rails-authorization-basics/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 20:47:09 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Access Control]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[Authorization]]></category>
		<category><![CDATA[cancan]]></category>
		<category><![CDATA[control]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=43</guid>
		<description><![CDATA[Libraries for Authorization controls in Ruby on Rails are not nearly is prolific as they are with Authorization. The one I typically use is Cancan. The thing I like about Cancan is that it provides fairly granular model level controls. You have to do the checks&#8212;Rails won&#8217;t do them for you&#8212;but they are fairly straightforward. [...]]]></description>
			<content:encoded><![CDATA[<p>Libraries for Authorization controls in Ruby on Rails are not nearly is prolific as they are with Authorization. The one I typically use is Cancan.</p>
<p>The thing I like about Cancan is that it provides fairly granular model level controls. You have to do the checks&mdash;Rails won&#8217;t do them for you&mdash;but they are fairly straightforward. The other thing I like about it is that it provides some Controller level controls through a before filter you can include that will pull up the model, load the object, and check permissions before loading the Controller action. </p>
<p>Ideally, a good Authorization library allows this level of control at all three levels of your application.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/Fo_2H_jyGYs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/007-rails-authorization-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC7Authorization.mp3" length="13550789" type="audio/mpeg" />
			<itunes:keywords>access,Authorization,cancan,control</itunes:keywords>
	<itunes:subtitle>Libraries for Authorization controls in Ruby on Rails are not nearly is prolific as they are with Authorization. The one I typically use is Cancan. - The thing I like about Cancan is that it provides fairly granular model level controls.</itunes:subtitle>
		<itunes:summary>Libraries for Authorization controls in Ruby on Rails are not nearly is prolific as they are with Authorization. The one I typically use is Cancan.

The thing I like about Cancan is that it provides fairly granular model level controls. You have to do the checks—Rails won't do them for you—but they are fairly straightforward. The other thing I like about it is that it provides some Controller level controls through a before filter you can include that will pull up the model, load the object, and check permissions before loading the Controller action. 

Ideally, a good Authorization library allows this level of control at all three levels of your application.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>11:17</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC7Authorization.mp3" fileSize="13550789" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/007-rails-authorization-basics/</feedburner:origLink></item>
		<item>
		<title>006 RC Ruby on Rails Authentication Basics</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/_OFDnzMK2vs/</link>
		<comments>http://railscoach.com/006-rc-ruby-on-rails-authentication-basics/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 17:47:42 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Authentication]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[authlogic]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[devise]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[restful_authentication]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[salt]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=35</guid>
		<description><![CDATA[In a lot of web applications, you need to control who can access your data. Authentication is the key to this type of security. Ruby on Rails has some plugins and gems that make authentication pretty easy. Here are a few: restful-authentication authlogic devise When putting authentication together, make sure that your authentication schema provides [...]]]></description>
			<content:encoded><![CDATA[<p>In a lot of web applications, you need to control who can access your data. Authentication is the key to this type of security. Ruby on Rails has some plugins and gems that make authentication pretty easy. Here are a few:</p>
<ul>
<li><a href="https://github.com/technoweenie/restful-authentication">restful-authentication</a></li>
<li><a href="https://github.com/binarylogic/authlogic">authlogic</a></li>
<li><a href="https://github.com/plataformatec/devise">devise</a></li>
</ul>
<p>When putting authentication together, make sure that your authentication schema provides encryption for your passwords and a salt to make it more difficult for hackers to figure out which users are using the same password.</p>
<p>Also make sure that your failed authentication messages read &#8220;Your username or password is incorrect.&#8221; rather than pointing out which specific field is incorrect. This will prevent hackers from mining your usernames and trying to guess their passwords.</p>
<p>Lost password messages should also report success every time. Since you won&#8217;t be able to decrypt the passwords, you should always give a message like &#8220;An email message has been sent to you to reset your password&#8221; even if the username or email isn&#8217;t in your system.</p>
<p>Finally, to avoid problems where people are sniffing networks with tools like <a href="http://codebutler.com/firesheep">firesheep</a> to get usernames, passwords, and session cookies. Make sure that you&#8217;re encrypting your logins and sessions with SSL. Use the <a href="https://github.com/rails/ssl_requirement">ssl_requirement</a> plugin to take care of this for you.</p>
<p>Here&#8217;s the video:</p>
<p><iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/78nGDEEHVtY" frameborder="0" allowfullscreen></iframe></p>
<p>And the transcript:</p>
<p>  Rails Coach Podcast episode 6. </p>
<p>Hey everybody and welcome back to the Rails Coach Podcast with Charles Max Wood, that’s me. This week we’re going to be talking about authentication. But before we get started I really want to talk about where things have been going with this podcast. It’s kind of been an exploratory mission for me to kind of figure out how I want to talk about Rails. The thing is that I’ve had the Teach me to Code podcast for awhile, and I really didn’t feel like once I moved it from the Rails Coach podcast to the Teach Me to Code Podcast that I could talk as deeply about Rails, and so I wanted to talk about that there. </p>
<p>The problem is that I’ve been talking about things that I feel like are better explained through demonstration as opposed t o actually talking about principles that people should know when they’re programming in Rails. So what I’m going to do is I’m going to kind of change tactics a little bit. So I’m not going to go into as much things like; you should use this tool, you should use that tool. Well, I am, but I’m not going to go into how they’re used, I’m not going to go into what they are. What I’m going to try and do instead is I’m going to talk about general principles around certain things that are relevant to Rails. So, for example, this week I’m going to be talking about authentication, so I’ll probably bring up a few plugins or gems that you can use for authentication and I’ll talk about a few of the principles that define good practices for these different things. </p>
<p>So in this case I&#8217;m going to be talking about authentication, and there are things that I see that people generally get right, and there a few things that I see that generally people don’t get right. I see these things, some of these things, done on these huge sites that have thousands and thousands of users and I’m flabbergasted that this is there because it’s so simple to just write a script that takes advantage of some of this stuff. And so I&#8217;m just going to jump right in on the authentication stuff. </p>
<p>First off, I just want to talk a bit about the history of authentication with Rails. It all kind of started, as far as I can tell, with the restful-authentication plugin that was written by Rick Olson. This was probably four or five years ago. And restful-authentication took advantage of the RESTful approach that Rails had implemented at the time and proved an authentication scheme where it used the RESTful paths like GET and POST and PUT and DELETE, to manage sessions, and so sessions were the resources that the restful-authentication handled. So if you logged in it was new session was basically what you were doing. And so you would do GET, a GET on session/new. And if you were doing, when you created your session then you would post a session or sessions, and when you would logout you would post a DELETE to sessions and it would log you out, and it follows the same RESTful scheme that Rails follows. And most of the plugins that you see, nowadays, for Rails follow the same scheme. So they do the same thing, they use the RESTful routes for that resource. </p>
<p>Another one that I used later on was Authlogic. And that was something that I think a lot of people were using a year or two ago. And it worked really well with Rails 2. I haven’t actually tried using it with Rails 3 and that’s because I had a friend of mine turn me on to Devise right after Rails 3 was released. </p>
<p>Devise is nice because it actually includes some generators and does 99% of the work for you. And, authentication, it’s nice to know what’s going on, but Authlogic was kind of complicated and Devise is also kind of complicated but it doesn’t involve as much to get set up, and so it’s a pretty handy little gem there. And all you have to do to get it is just &#8220;gem install devise&#8221; or include it in your Gemfile in Rails. </p>
<p>Anyway, one other thing that these and most good authentication schemes have is, they actually encrypt the password. And this is important because if somebody steals your database or, let’s say, you do a database dump of your database and you import it to your developer machine so you can work on it, you have all these passwords in the wild and if they’re stored in clear text then you’re just begging for someone to come in and take advantage of them. So you should be encrypting your password. </p>
<p>Now, one of the companies that I work for they encrypted their passwords but they didn’t provide what’s termed a ‘password salt’. And what the ‘salt’ is, is it’s actually a string. It’s added to the password before it’s encrypted. And the reason that you want a password salt is because if you don’t include on and you’re using the same encryption scheme for all of the passwords then if you figure out one user’s password, then you can figure out what anyone else’s password is, if it’s the same. So, for example, if somebody put in the password ‘password’ and you just used an encryption scheme and no salt, then all of those passwords which are just the word ‘password’ would encrypt to the same string in the database. So then all you would have to do is load this database up, do query against it, find all the other ones that have the same string in the password, in the encrypted password, and you’re golden. You have access to probably a few hundred accounts and you can go in and take advantage of them that way. </p>
<p>With the password salt, what it does is because you have like &#8220;password-123-salt&#8221;, which is, let’s just say that the salt is the word salt, what happens is then when you encrypt it then your password, even though it’s the word ’password’, and John’s password, even though it’s the word ‘password’, he have a different salt so they encrypted different values, different strings. And that works really nicely to help kind of obfuscate what’s going on. It makes it harder to figure out how to get in and you have to, if you can reverse the encryption then that works to get the password, but typically people are using hashes and just a hexdigest on a hash, so they’re using SHA or I’ve seen people use bcrypt, or a few others. </p>
<p>Anyway, so basically it’s not even reversible. There’s no encryption key to get to reverse the encryption on the password because ultimately that’s not the way they work. What they do instead is, when you authenticate what it does is it takes your username and your password that you pass in and it uses the password and it actually re-encrypts the password and it compares the encrypted passwords. If a site is not doing this then what you’ll sometimes see is when you request your password, when you go through their ‘forgot password’ stuff, they’ll email you back you’re actual password. And if they can give you back your actual password, in my opinion that’s not as secure as doing the other way, where you actually hash the password. The reason is, is because then if somebody gets in they can read a little bit of code, they can figure out where the encryption key is stored and then they can get everyone’s password. It’s one or two steps away from storing it in clear. It does protect if they only get the database and not the code that encrypts and de-crypts, but the hashes are pretty solid an really difficult to reverse so it’s a much cleaner and simpler way. </p>
<p>Now, I’ve seen the encrypted password stored in a different database field from the password salt and I’ve actually also seen it where the encrypted password and the password salt are just concatenated and stored in one string. And I think that, I always thought that was interesting, putting it in one string, because ultimately then, they have to figure out what part of the string is the salt. So you could stick it in the middle. You could stick it at the end; I think most of them stick it at the end. And I think that’s reasonable too because basically what you wind up with then is they have to know how many characters long your salt is and how many characters long your encrypted password is. And if they can’t figure that out then they can’t hack your password. So it’s just another step, another way of handling that. </p>
<p>Now, one other thing that I’ve seen done on these, on the ‘forgot password’ pages, that people do that I think is nuts is they actually, you put in your email address, typically, or a user name. And so you stick in the username and then what happens is when you click ‘OK’ like send me my password or send me a link to reset my password, which is what they should be doing (sending you a link, not sending you the password. When you put in a username or email address that doesn’t work, that’s not in the system, it’ll tell you that email address isn’t in the system. And if you can login with the email address then what you just got there is you got a, ‘Hi, this will tell you whether you’ve got a valid account name’, and just knowing that is half the battle. If you have and account name then all you have to do is just figure out what the password is. </p>
<p>So it’s another thing that you want to do. Every time that you fail to login it should tell you that the username or the password is incorrect. It shouldn’t tell you for example, that username is incorrect or the just the password is incorrect. It should tell you that one of the two is incorrect and then they can figure out, the user should be able to determine, OK the username is wrong or the password’s wrong. But don’t tell them which one’s wrong because that’s another way for people to start getting usernames and start trying to figure out how to hack your system. So whenever you give some kind of failure message just give a success message or give a general message that tell them that something is wrong. Or in the case of the ‘forgot password’ that they’ll get an email and then, if they actually own the email address, then they can get an email that says actually this email doesn’t appear in our system. And that’ll protect things. </p>
<p>One other thing I’ve seen with a lot of smaller sites and, you know, it’s kind of, I don’t know, this is the sys-admin in me jumping on this, but it’s something that you should consider, especially if your site does get big or you’re providing a paid service, is do you use an SSL encryption on your authentication. And the reason is is because there are programmes out there like Firesheep, which is a plugin for Firefox , that can actually sniff the network. And they’ll sniff it and if it’s not encrypted they can pick up the username and password off of the traffic. And so if they’re on a public network with some guy that’s trying to hack something, I think the big one for this was actually Facebook. But in general you really want to have that encrypted so that you’re protecting your users against an attack like this. And it’s critically important once start getting big and became a target for this kind of hacking. And if you take care of then what happens is the connection is encrypted and then they’re just getting garbled junk. I understand that getting an SSL key that the browsers will trust costs money, but again, if you’re charging for a service you can probably get one for $40/50, I mean, worst case scenario, I don t remember, last time I priced they were about that, the ones that I was looking at. And they’re signed by VeriSign, or somebody. And that will, the browser will just trust it and then you just make it work from there. So I highly recommend that. There is a plugin that was extracted out of the Rails core that allows you to do an SSL requirement and that’s defiantly something you should look into. Now, in general authentication is important because you want to control access to certain things, just make sure that you’re doing it securely. </p>
<p>In Rails 3 I think the most popular one that people are using is Devise. That’s D-e-v-i-s-e, I’ll put a link in the show notes. In Rails 2 I think it was split 50/50 between Authlogic and RESTful authentication. There are a bunch more out there, you can go and find them, they do all kinds of stuff. There are some that do OpenID, some that do OAuth some that do&#8230;I mean; they’re all over the place. So anyway, what I would do is I would just go and check them out. Install them in a dummy project, see what the migrations give you in your database and make sure that they’re encrypting the passwords and that you can set it up so that when you get a failure that your failure messages don’t give away that you’re, the username is correct or incorrect. And that when they forget the password that you provide them a link, a secure link, where they can come back and set they’re password. And by all means, just encrypt the thing. </p>
<p>Now if you need help with any of this, if you need help getting Rails set up or getting authentication working the way you want, feel free to give me a call, 8013676164. You can also email me chuck@teachmetocode.com If you want more of this kind of stuff I&#8217;m on Twitter as <a href="http://twitter.com/cmaxw">cmaxw</a>. My name is Charles Max Wood.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/_OFDnzMK2vs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/006-rc-ruby-on-rails-authentication-basics/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC_6_Ruby_on_Rails_Authentication_Basics.mp3" length="18356797" type="audio/mpeg" />
			<itunes:keywords>authentication,authlogic,database,devise,encryption,password,rails,restful_authentication,ruby,ruby on rails,salt,ssl</itunes:keywords>
	<itunes:subtitle>In a lot of web applications, you need to control who can access your data. Authentication is the key to this type of security. Ruby on Rails has some plugins and gems that make authentication pretty easy. Here are a few:  restful-authentication </itunes:subtitle>
		<itunes:summary>In a lot of web applications, you need to control who can access your data. Authentication is the key to this type of security. Ruby on Rails has some plugins and gems that make authentication pretty easy. Here are a few:

	restful-authentication
	authlogic
	devise


When putting authentication together, make sure that your authentication schema provides encryption for your passwords and a salt to make it more difficult for hackers to figure out which users are using the same password.

Also make sure that your failed authentication messages read "Your username or password is incorrect." rather than pointing out which specific field is incorrect. This will prevent hackers from mining your usernames and trying to guess their passwords.

Lost password messages should also report success every time. Since you won't be able to decrypt the passwords, you should always give a message like "An email message has been sent to you to reset your password" even if the username or email isn't in your system.

Finally, to avoid problems where people are sniffing networks with tools like firesheep to get usernames, passwords, and session cookies. Make sure that you're encrypting your logins and sessions with SSL. Use the ssl_requirement plugin to take care of this for you.

Here's the video:



And the transcript:


  Rails Coach Podcast episode 6. 

Hey everybody and welcome back to the Rails Coach Podcast with Charles Max Wood, that’s me. This week we’re going to be talking about authentication. But before we get started I really want to talk about where things have been going with this podcast. It’s kind of been an exploratory mission for me to kind of figure out how I want to talk about Rails. The thing is that I’ve had the Teach me to Code podcast for awhile, and I really didn’t feel like once I moved it from the Rails Coach podcast to the Teach Me to Code Podcast that I could talk as deeply about Rails, and so I wanted to talk about that there. 

The problem is that I’ve been talking about things that I feel like are better explained through demonstration as opposed t o actually talking about principles that people should know when they’re programming in Rails. So what I’m going to do is I’m going to kind of change tactics a little bit. So I’m not going to go into as much things like; you should use this tool, you should use that tool. Well, I am, but I’m not going to go into how they’re used, I’m not going to go into what they are. What I’m going to try and do instead is I’m going to talk about general principles around certain things that are relevant to Rails. So, for example, this week I’m going to be talking about authentication, so I’ll probably bring up a few plugins or gems that you can use for authentication and I’ll talk about a few of the principles that define good practices for these different things. 

So in this case I'm going to be talking about authentication, and there are things that I see that people generally get right, and there a few things that I see that generally people don’t get right. I see these things, some of these things, done on these huge sites that have thousands and thousands of users and I’m flabbergasted that this is there because it’s so simple to just write a script that takes advantage of some of this stuff. And so I'm just going to jump right in on the authentication stuff. 

First off, I just want to talk a bit about the history of authentication with Rails. It all kind of started, as far as I can tell, with the restful-authentication plugin that was written by Rick Olson. This was probably four or five years ago. And restful-authentication took advantage of the RESTful approach that Rails had implemented at the time and proved an authentication scheme where it used the RESTful paths like GET and POST and PUT and DELETE, to manage sessions, and so sessions were the resources that the restful-authentication handled.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>15:18</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC_6_Ruby_on_Rails_Authentication_Basics.mp3" fileSize="18356797" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/006-rc-ruby-on-rails-authentication-basics/</feedburner:origLink></item>
		<item>
		<title>005 RC Testing Tools for Rails</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/q9tSWjrK5So/</link>
		<comments>http://railscoach.com/005-rc-testing-tools-for-rails/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 04:29:49 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Testing]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[factorygirl]]></category>
		<category><![CDATA[flexmock]]></category>
		<category><![CDATA[integration tests]]></category>
		<category><![CDATA[mocha]]></category>
		<category><![CDATA[models]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[testunit]]></category>
		<category><![CDATA[unit tests]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=28</guid>
		<description><![CDATA[There are a lot of tools for testing Rails. Here are links to several of the ones mentioned in this podcast. Test Unit RSpec Cucumber Mocha Flexmock Factory Girl You can find my interview with David Heinemeier Hansson here, and my response to his comments on Twitter here. Finally, here are a few other resources [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of tools for testing Rails. Here are links to several of the ones mentioned in this podcast.</p>
<ul>
<li><a href="http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html">Test Unit</a></li>
<li><a href="http://rspec.info">RSpec</a></li>
<li><a href="http://cukes.info">Cucumber</a></li>
<li><a href="http://mocha.rubyforge.org/">Mocha</a></li>
<li><a href="http://flexmock.rubyforge.org">Flexmock</a></li>
<li><a href="https://github.com/thoughtbot/factory_girl">Factory Girl</a></li>
</ul>
<p>You can find my interview with David Heinemeier Hansson <a href="http://teachmetocode.com/podcast/tmtc-48-david-heinemeier-hansson/">here</a>, and my response to his <a href="http://www.rubyinside.com/dhh-offended-by-rspec-debate-4610.html">comments on Twitter</a> <a href="http://teachmetocode.com/podcast/52-tmtc-the-dhh-rspec-and-other-debates/">here</a>.</p>
<p>Finally, here are a few other resources for you to get started with testing Ruby on Rails.</p>
<ul>
<li><a href="http://teachmetocode.com/screencasts/introduction-to-outside-in-development-with-cucumber/">Introduction to Outside-In Development with Cucumber</a></li>
</ul>
<p>Here&#8217;s a transcript of the podcast:<br />
<span id="more-28"></span><br />
Rails Coach Podcast, Episode 5</p>
<p>Hey, everybody, and welcome back to another Rails Coach podcast. This is Charles Max Wood and this week we’re going to go into testing Rails. You can test Rails in a lot of different ways, and we’re going to talk about some of the libraries that are around for doing that. I’m also going to talk about my approach to it; some of the things that I’m thinking about doing or changing – and I guess we should just dive right in.</p>
<p>First off, I want to point out that there’s been a discussion on Twitter about Test Unit vs. RSpec. Now, if you’re not familiar with Ruby on Rails or who David Heinemeier Hansson is, then I recommend that you go listen to the “Teach Me To Code” podcast. I interviewed David on that podcast and talked a little bit about Ruby on Rails. And that will give you kind of a feel for who he is. He’s the guy that wrote Ruby on Rails and he is the technical partner at 37signals that makes Basecamp and Highrise and a bunch of other products that I used to use. But I don’t anymore. And that’s not the topic for this podcast. Anyway, we’re going to go into some of the things that are available for testing Ruby on Rails. I’m going to go into, first off, the discussion that was had over RSpec and Test Unit. David Heinemeier Hansson, a while back, said that he and 37signals, they used Test Unit, and that Test Unit and Mocha, which is a mocking and stubbing framework were basically all you need for good Ruby on Rails testing. Then he later said that he was a little disappointed by the proliferation of RSpec and Cucumber because he felt like they were a little too complicated and had been cargo-culted upon the Ruby on Rails community. And that started a whole lot of discussion over whether or not RSpec and Cucumber were the right tool. There were people who came out and said, Oh yeah, David’s right. Test Unit all the way. And other people came out and said, Hey wait a minute, RSpec all the way. David, you’re an idiot. And some people had kind of the reaction that I had where we thought about it for a minute and said, I’ve been using Test Unit or RSpec for a while, and I really ought to explore what the differences are and why I might want to use one over the other. I really haven’t had a chance to do that. However, I have used both; I’ve used both on different projects. And so I think it is worth discussing testing tools that are available for Ruby on Rails and what you can do to learn this stuff. So we’ll jump right in here. First off, I use – I’ll let you know – I use RSpec and Cucumber, and I use Factory Girl to generate my objects that I am going to be testing against. And then I use FlexMark for mocking and stubbing. That’s more or less what I use. Now, with Cucumber I use Capybara. And then I’ve recently started using Culerity and Celerity to test my JavaScript. And that has been working, actually, really well.</p>
<p>So, basically I use RSpec to do some of the testing in Cucumber. For example, you can write your assertions or dot-shoulds in Cucumber steps, and if they fail then your Cucumber scenario fails. RSpec I also use for my unit tests. And unit tests are just class-level tests. They usually use some method of mocking or stubbing to isolate your object so that you can test one way or the other, or if you have a dependent object, then you don’t necessarily have to mock that out. It’s a matter of preference as to how deeply and how thoroughly you mock things out. In my case, I really feel like in a lot of cases people mock things out that they really don’t need to. Anyway, I’m not really going to go into that either, other than to say if it’s much simpler just to create a dependent object, do it. If there is a deep algorithm around or something that you haven’t implemented, then you can go ahead and mock or stub an object so that it will behave the way that you need it to in order to test the functionality in your unit test. If it is complicated functionality then you probably should be mocking it, just because if the implementation changes, your test result doesn’t change because the output changed. Because basically, in your unit test, when you are testing something that depends on another object, you should really only be testing its dependency on state or output from the other object. So, anyway, I use RSpec and RSpec gives you kind of a name-spacing feature, where you can do Describe, and then you give it a class name and then a block. And the block is a Do with code in between it and an End. And so then inside there you can do It, and then you give it a string that describes the functionality that you are testing, and another block. And then in that block you can do setup; you can do the actual test. So you get in and you can say, If I set this user’s name to Chuck, then when I retrieve the name from the user, it should be Chuck. And that is kind of a contrived example because in a lot of cases, that’s simple enough to where you would just assume that it is the case and you don’t necessarily need to deeply test it.</p>
<p>But anyway, I also use Cucumber. And Cucumber is kind of the top-down testing. It is built around an approach called BDD, or behavior-driven development.  And the idea behind Cucumber is that you can write your specifications in plain English, and then you write steps that parse those – well, you write handlers for the steps that parse the step, and take the information from the step and actually execute it.</p>
<p>So what happens is, you can write something like, given I am logged in, and then what that does is you write a handler that can go and actually goes through the motions of logging you into the website. Then the next step could be “and I am on the home page.” So then it takes you to the home page, slash-home. When I click on Log Out, then it actually triggers a click event on the logout link. Then I should see “You’ve been logged out successfully.” And so then it looks for that content on the page. And it does everything from the top all the way down to the bottom, so you are testing not only your controllers and your views and your models, but you are also testing the interactions between them to make sure that it is displaying the right information. When you are testing things like controllers – when you are unit testing your controllers &#8212; in Rails if you use Test Unit then under your test folder you will see Unit, Functional, and Integration. And the Functional tests are your controller tests. You may also see tests for your views and other things. That’s something that they’ve added since I’ve started programming in Rails. I’m not a big fan of testing the views, and I’ll go into why in a minute. But anyway, when you are testing your controllers, then a lot of times what you are going to do is you are going to mock out your models. And then that way they are not dependent on the functionality of the model; they’re just dependent on the values that they are going to get back from the model. And so then what you can do is you can test and make sure that if you get a certain thing back from a method that you wrote on the model, then that gets passed through to the view.</p>
<p>Usually your controllers are pretty slim. Most of your functionality is in your model. So testing the controllers is really, really simple. Testing the views is a little tricky because you really can’t test good layout. There’s not a good way of doing that. So you typically wind up eyeballing it. So testing the view really means making sure that the right data shows up. And in that case, I feel like the integration tests are sufficient. Because then what it does is it makes sure that the data is in the database; it shows up in the view. And that’s exactly what you want. So I never really test the views.</p>
<p>You can also test things like routes and other things. And some of those are worth it; some of them probably aren’t. It really just depends on your understanding of things and your making sure that things work the way that you want them to. Now the testing is really important. I do TDD at the very least, and typically quite a bit of BDD. Which means that I write unit tests before I write model code. And I write Cucumber scenarios before I write the overall feature. And the reason that I do that is so that I understand how the interaction should affect the overall behavior of the application.</p>
<p>And it’s nice because if I really need to, then I can actually send the Cucumber feature over to my client, and they can look at it and say, Yes, this is how I want it to work. Or, No, it’s not. Or, I don’t understand. And then we can kind of work from there.</p>
<p>So it really is quite handy to have. And that’s why I use Cucumber. If I weren’t collaborating with my clients, then I would probably be tempted just to use the integration portion of the testing frameworks, either in RSpec or Test Unit. And simply use the Capybara library and test things directly, rather than writing out the English steps, because I find those a little bit tedious as a programmer. But I find that they are useful if I am collaborating with somebody that is not a programmer.</p>
<p>Anyway, those are some general thoughts on testing Ruby on Rails. You can go and find – I’ll put up some links to some resources on Cucumber and RSpec and Test Unit and learning how to use some of these things. And hopefully this helps you get started testing your Ruby on Rails application. You’ll find that as you get into the Rails community that this is a big deal. So, as you continue on your journey of learning Ruby on Rails, you’ll start to pick up – Oh, this is important, testing is important. And you’ll start to see why people do the testing and what they gain out of it.</p>
<p>Real quickly, I feel like I gain a couple of things from testing, especially TDD. One is that I feel like I understand a problem before I approach it, which really helps me write the code better. The other thing is, I know immediately if somebody else has changed something that breaks the expected functionality, because I’ve put these expectations on the code. So if somebody else is coding in the same code base and they break something, when I run the tests then I’ll get notified. And if I am running continuous integration, then that’s something that really works in my favor as far as letting me know immediately, when I checked in, that something broke. And letting them know too. Really, it’s just a good exercise in thinking about these things and writing great code. So that’s what I like about the approach.</p>
<p>Now, if you want to get a hold of me, you can get a hold of me at chuck@teachmetocode.com<br />
If you want some coaching or you want to learn Ruby on Rails, then you can call me at that number or email me. You can call me at 801- 367-6164. That’s my cell, so you can get me just about anytime and I’ll pick up. I’ll be happy to walk you through whatever you are working on and help you get going.</p>
<p>If you have a Ruby or Rails or Sinatra or some application that you want me to build for you, I do that too. You can reach me in those same ways. I’m also working on posting the videos to these. And I just got some new software that does – what is it? – It’s transcription. So I got some software that should help me transcribe these episodes so that you can benefit from them in text as well as in audio. And I’m posting videos. It’s just kind of a talking head right now. On YouTube. So you can go on YouTube and see me talking to you, if you would prefer.</p>
<p>Those are great ways to do it. The show notes are at RailsCoach.com. Thank you for listening.</p>
<p>Finally, here&#8217;s the video version:</p>
<p><iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/v9j0QFxl5RU" frameborder="0" allowfullscreen></iframe></p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/q9tSWjrK5So" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/005-rc-testing-tools-for-rails/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC4_TestingRails.mp3" length="16236177" type="audio/mpeg" />
			<itunes:keywords>bdd,cucumber,factorygirl,flexmock,integration tests,mocha,models,rspec,ruby on rails,tdd,testing,testunit</itunes:keywords>
	<itunes:subtitle>There are a lot of tools for testing Rails. Here are links to several of the ones mentioned in this podcast.  Test Unit   RSpec   Cucumber   Mocha   Flexmock   Factory Girl You can find my interview with David Heinemeier Hansson here,</itunes:subtitle>
		<itunes:summary>There are a lot of tools for testing Rails. Here are links to several of the ones mentioned in this podcast.

	Test Unit
	RSpec
	Cucumber
	Mocha
	Flexmock
	Factory Girl


You can find my interview with David Heinemeier Hansson here, and my response to his comments on Twitter here.

Finally, here are a few other resources for you to get started with testing Ruby on Rails.

	Introduction to Outside-In Development with Cucumber


Here's a transcript of the podcast:

Rails Coach Podcast, Episode 5
 
Hey, everybody, and welcome back to another Rails Coach podcast. This is Charles Max Wood and this week we’re going to go into testing Rails. You can test Rails in a lot of different ways, and we’re going to talk about some of the libraries that are around for doing that. I’m also going to talk about my approach to it; some of the things that I’m thinking about doing or changing – and I guess we should just dive right in.
 
First off, I want to point out that there’s been a discussion on Twitter about Test Unit vs. RSpec. Now, if you’re not familiar with Ruby on Rails or who David Heinemeier Hansson is, then I recommend that you go listen to the “Teach Me To Code” podcast. I interviewed David on that podcast and talked a little bit about Ruby on Rails. And that will give you kind of a feel for who he is. He’s the guy that wrote Ruby on Rails and he is the technical partner at 37signals that makes Basecamp and Highrise and a bunch of other products that I used to use. But I don’t anymore. And that’s not the topic for this podcast. Anyway, we’re going to go into some of the things that are available for testing Ruby on Rails. I’m going to go into, first off, the discussion that was had over RSpec and Test Unit. David Heinemeier Hansson, a while back, said that he and 37signals, they used Test Unit, and that Test Unit and Mocha, which is a mocking and stubbing framework were basically all you need for good Ruby on Rails testing. Then he later said that he was a little disappointed by the proliferation of RSpec and Cucumber because he felt like they were a little too complicated and had been cargo-culted upon the Ruby on Rails community. And that started a whole lot of discussion over whether or not RSpec and Cucumber were the right tool. There were people who came out and said, Oh yeah, David’s right. Test Unit all the way. And other people came out and said, Hey wait a minute, RSpec all the way. David, you’re an idiot. And some people had kind of the reaction that I had where we thought about it for a minute and said, I’ve been using Test Unit or RSpec for a while, and I really ought to explore what the differences are and why I might want to use one over the other. I really haven’t had a chance to do that. However, I have used both; I’ve used both on different projects. And so I think it is worth discussing testing tools that are available for Ruby on Rails and what you can do to learn this stuff. So we’ll jump right in here. First off, I use – I’ll let you know – I use RSpec and Cucumber, and I use Factory Girl to generate my objects that I am going to be testing against. And then I use FlexMark for mocking and stubbing. That’s more or less what I use. Now, with Cucumber I use Capybara. And then I’ve recently started using Culerity and Celerity to test my JavaScript. And that has been working, actually, really well.

So, basically I use RSpec to do some of the testing in Cucumber. For example, you can write your assertions or dot-shoulds in Cucumber steps, and if they fail then your Cucumber scenario fails. RSpec I also use for my unit tests. And unit tests are just class-level tests. They usually use some method of mocking or stubbing to isolate your object so that you can test one way or the other, or if you have a dependent object, then you don’t necessarily have to mock that out. It’s a matter of preference as to how deeply and how thoroughly you mock things out. In my case,</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>13:32</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC4_TestingRails.mp3" fileSize="16236177" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/005-rc-testing-tools-for-rails/</feedburner:origLink></item>
		<item>
		<title>004 RC Ruby on Rails Model Validations</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/-o0trDUBrio/</link>
		<comments>http://railscoach.com/004-rc-ruby-on-rails-model-validations/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 22:00:17 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=24</guid>
		<description><![CDATA[You can get the video version of this podcast here. I&#8217;ve also updated the audio files for episodes 2 &#038; 3 so you can hear them now. Sorry for the trouble. Ruby on Rails provides some excellent ways to validate the data you save in your models. Validations are methods called within the class definition [...]]]></description>
			<content:encoded><![CDATA[<p>You can get the video version of this podcast <a href="http://www.youtube.com/watch?v=KjS3WCIcFm0&#038;feature=youtube_gdata_player">here</a>.</p>
<p>I&#8217;ve also updated the audio files for episodes 2 &#038; 3 so you can hear them now. Sorry for the trouble.</p>
<p>Ruby on Rails provides some excellent ways to validate the data you save in your models. Validations are methods called within the class definition specifying an attribute to check and what to look for.</p>
<pre class="brush: ruby; highlight: [5, 15]; html-script: true">
class User < ActiveRecord::Base
  validates_presence_of :username
end
</pre>
<p>Validations are called when you call 'save', 'create', or 'valid?'. If there are validation errors, create will return a new but not saved (to the database) version of the object you were creating. 'save' and 'valid?' will return false. </p>
<p>You can get validation errors from the object by calling 'errors'.</p>
<p>I also go over some of the common validations in the podcast.</p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/-o0trDUBrio" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/004-rc-ruby-on-rails-model-validations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC4_ModelValidations.mp3" length="15396079" type="audio/mpeg" />
		<itunes:subtitle>You can get the video version of this podcast here. - I've also updated the audio files for episodes 2 &amp; 3 so you can hear them now. Sorry for the trouble. - Ruby on Rails provides some excellent ways to validate the data you save in your models.</itunes:subtitle>
		<itunes:summary>You can get the video version of this podcast here.

I've also updated the audio files for episodes 2 &amp; 3 so you can hear them now. Sorry for the trouble.

Ruby on Rails provides some excellent ways to validate the data you save in your models. Validations are methods called within the class definition specifying an attribute to check and what to look for.


class User &lt; ActiveRecord::Base
  validates_presence_of :username
end


Validations are called when you call 'save', 'create', or 'valid?'. If there are validation errors, create will return a new but not saved (to the database) version of the object you were creating. 'save' and 'valid?' will return false. 

You can get validation errors from the object by calling 'errors'.

I also go over some of the common validations in the podcast.</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>12:50</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC4_ModelValidations.mp3" fileSize="15396079" type="audio/mpeg" /><itunes:keywords>ruby,rails,ruby,on,rails,rails,3,rails,tutorial,ruby,on,rails,tutorial,rails,tutorial,ruby,rails,tutorial</itunes:keywords><feedburner:origLink>http://railscoach.com/004-rc-ruby-on-rails-model-validations/</feedburner:origLink></item>
		<item>
		<title>003 RC Single Table Inheritance (STI)</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/FmWDediMazg/</link>
		<comments>http://railscoach.com/003-single-table-inheritance-sti/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 05:57:33 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[convention]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[models]]></category>
		<category><![CDATA[single table inheritance]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=17</guid>
		<description><![CDATA[Single Table Inheritance is a slightly advanced topic in Ruby on Rails. It stems from class inheritance, which is a core Object Oriented Programming principle. In Ruby, if you inherit one class from another, you use the &#8216;&#60;&#8217; operator. Here&#8217;s an example: class Truck < Car end In Rails, this gets tricky because when inheriting [...]]]></description>
			<content:encoded><![CDATA[<p>Single Table Inheritance is a slightly advanced topic in Ruby on Rails. It stems from class inheritance, which is a core Object Oriented Programming principle.</p>
<p>In Ruby, if you inherit one class from another, you use the &#8216;&lt;&#8217; operator. Here&#8217;s an example:</p>
<pre class="brush: ruby; highlight: [5, 15]; html-script: true">
class Truck < Car

end
</pre>
<p>In Rails, this gets tricky because when inheriting a Model, do you use the parent models connection and table? or your own? By convention, you use the parent's table, which means that you need some way of differentiating the Trucks from the rest of the Cars.</p>
<p>So, by adding a 'type' column to your table&mdash;which is a string&mdash;you activate a Rails convention that stores the subclass' classname in the type column. So, in the case of the Truck class, you'd have all of the Car's attributes and a type column that is populated with the string "Truck" to denote that it's a truck.</p>
<p>When doing a Model lookup on your database, Rails tacks on the "AND type = 'Truck'" for you.</p>
<p><a href="http://traffic.libsyn.com/railscoach/RC3_SingleTableInheritance.mp3">Download this Episode</a></p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/FmWDediMazg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/003-single-table-inheritance-sti/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC3_SingleTableInheritance.mp3" length="22978414" type="audio/mpeg" />
			<itunes:keywords>convention,database,inheritance,models,single table inheritance,table</itunes:keywords>
	<itunes:subtitle>Single Table Inheritance is a slightly advanced topic in Ruby on Rails. It stems from class inheritance, which is a core Object Oriented Programming principle. - In Ruby, if you inherit one class from another, you use the '&lt;' operator.</itunes:subtitle>
		<itunes:summary>Single Table Inheritance is a slightly advanced topic in Ruby on Rails. It stems from class inheritance, which is a core Object Oriented Programming principle.

In Ruby, if you inherit one class from another, you use the '&lt;' operator. Here's an example:


class Truck &lt; Car

end


In Rails, this gets tricky because when inheriting a Model, do you use the parent models connection and table? or your own? By convention, you use the parent's table, which means that you need some way of differentiating the Trucks from the rest of the Cars.

So, by adding a 'type' column to your table—which is a string—you activate a Rails convention that stores the subclass' classname in the type column. So, in the case of the Truck class, you'd have all of the Car's attributes and a type column that is populated with the string "Truck" to denote that it's a truck.

When doing a Model lookup on your database, Rails tacks on the "AND type = 'Truck'" for you.

Download this Episode</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>9:34</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC3_SingleTableInheritance.mp3" fileSize="22978414" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/003-single-table-inheritance-sti/</feedburner:origLink></item>
		<item>
		<title>002 RC Model View Controller (MVC)</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/83ajpG5Pn6I/</link>
		<comments>http://railscoach.com/002-rc-model-view-controller-mvc/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 05:45:17 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[dispatcher]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[routes]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=12</guid>
		<description><![CDATA[This is a brief explanation of how Rails implements the MVC design pattern to create such an awesome framework for building websites. In a nutshell, when a request comes to a Ruby on Rails website, it&#8217;s handed the dispatcher. The dispatcher consults the routes provided in the application to determine which Controller and action to [...]]]></description>
			<content:encoded><![CDATA[<p>This is a brief explanation of how Rails implements the MVC design pattern to create such an awesome framework for building websites.</p>
<p>In a nutshell, when a request comes to a Ruby on Rails website, it&#8217;s handed the dispatcher. The dispatcher consults the routes provided in the application to determine which Controller and action to pass the request to. A Controller is a class which has methods called actions on it. The request is handled by a particular action on a controller.</p>
<p>The Controller may then respond by gathering data from the database through the Models. I can then convert the Models&#8217; data into text or pass it to a template called a View to return the response.</p>
<p>Most HTML responses (web pages) are returned by rendering Model data in a View.</p>
<p><a href="http://traffic.libsyn.com/railscoach/RC2_MVC.mp3">Download this Episode</a></p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/83ajpG5Pn6I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/002-rc-model-view-controller-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC2_MVC.mp3" length="24977674" type="audio/mpeg" />
			<itunes:keywords>controller,dispatcher,model,mvc,routes,ruby on rails,view</itunes:keywords>
	<itunes:subtitle>This is a brief explanation of how Rails implements the MVC design pattern to create such an awesome framework for building websites. - In a nutshell, when a request comes to a Ruby on Rails website, it's handed the dispatcher.</itunes:subtitle>
		<itunes:summary>This is a brief explanation of how Rails implements the MVC design pattern to create such an awesome framework for building websites.

In a nutshell, when a request comes to a Ruby on Rails website, it's handed the dispatcher. The dispatcher consults the routes provided in the application to determine which Controller and action to pass the request to. A Controller is a class which has methods called actions on it. The request is handled by a particular action on a controller.

The Controller may then respond by gathering data from the database through the Models. I can then convert the Models' data into text or pass it to a template called a View to return the response.

Most HTML responses (web pages) are returned by rendering Model data in a View.

Download this Episode</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>10:24</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC2_MVC.mp3" fileSize="24977674" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/002-rc-model-view-controller-mvc/</feedburner:origLink></item>
		<item>
		<title>001 RC Do I Need to Know Ruby?</title>
		<link>http://feedproxy.google.com/~r/railscoachpodcast/~3/jChFJ8MTBcI/</link>
		<comments>http://railscoach.com/001-rc-do-i-need-to-know-ruby/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 06:15:22 +0000</pubDate>
		<dc:creator>chuck@teachmetocode.com (Charles Max Wood)</dc:creator>
				<category><![CDATA[Rails Concepts]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[getting started]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://railscoach.com/?p=6</guid>
		<description><![CDATA[Some people wonder if they need to know Ruby to program Ruby on Rails. My answer is &#8220;kind of.&#8221; Ultimately, when you program in Ruby on Rails, you program in Ruby. That being said, you don&#8217;t need to know the ins and outs to get started with Ruby on Rails. I didn&#8217;t when I got [...]]]></description>
			<content:encoded><![CDATA[<p>Some people wonder if they need to know Ruby to program Ruby on Rails. My answer is &#8220;kind of.&#8221; Ultimately, when you program in Ruby on Rails, you program in Ruby.</p>
<p>That being said, you don&#8217;t need to know the ins and outs to get started with Ruby on Rails. I didn&#8217;t when I got started.</p>
<p>It does make a difference in understanding how Rails works once you get past the basics.</p>
<p><a href="http://traffic.libsyn.com/railscoach/RC1_Do_I_Need_To_Know_Ruby.mp3">Download this episode</a></p>
<img src="http://feeds.feedburner.com/~r/railscoachpodcast/~4/jChFJ8MTBcI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://railscoach.com/001-rc-do-i-need-to-know-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://traffic.libsyn.com/railscoach/RC1_Do_I_Need_To_Know_Ruby.mp3" length="22038814" type="audio/mpeg" />
			<itunes:keywords>basics,getting started,ruby,ruby on rails</itunes:keywords>
	<itunes:subtitle>Some people wonder if they need to know Ruby to program Ruby on Rails. My answer is "kind of." Ultimately, when you program in Ruby on Rails, you program in Ruby. - That being said, you don't need to know the ins and outs to get started with Ruby on R...</itunes:subtitle>
		<itunes:summary>Some people wonder if they need to know Ruby to program Ruby on Rails. My answer is "kind of." Ultimately, when you program in Ruby on Rails, you program in Ruby.

That being said, you don't need to know the ins and outs to get started with Ruby on Rails. I didn't when I got started.

It does make a difference in understanding how Rails works once you get past the basics.

Download this episode</itunes:summary>
		<itunes:author>Rails Coach</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:duration>9:11</itunes:duration>
	<media:content url="http://traffic.libsyn.com/railscoach/RC1_Do_I_Need_To_Know_Ruby.mp3" fileSize="22038814" type="audio/mpeg" /><feedburner:origLink>http://railscoach.com/001-rc-do-i-need-to-know-ruby/</feedburner:origLink></item>
	<copyright>(c) Intentional Excellence Productions LLC</copyright><media:credit role="author">Charles Max Wood</media:credit><media:rating>nonadult</media:rating><media:description type="plain">Rails Coach Podcast</media:description></channel>
</rss>
