<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Postpostmodern &#187; Rails</title>
	<atom:link href="http://postpostmodern.com/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://postpostmodern.com</link>
	<description>Speaking of web development.</description>
	<lastBuildDate>Tue, 08 Jun 2010 18:46:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A Body with Class</title>
		<link>http://postpostmodern.com/instructional/a-body-with-class/</link>
		<comments>http://postpostmodern.com/instructional/a-body-with-class/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 23:07:12 +0000</pubDate>
		<dc:creator>Jason Johnson</dc:creator>
				<category><![CDATA[Instructional]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://postpostmodern.com/?p=228</guid>
		<description><![CDATA[Ease section-specific styling by adding classes to your body tag.]]></description>
			<content:encoded><![CDATA[<h2>This Short Version</h2>

<p>Add a class attribute to your <body> tag for each part of the page&#8217;s path in the URL. E.g.: The page <em>http://example.com/about/history</em> should have a body tag that looks like <code>&lt;body class="about history"&gt;</code>. It makes styling those sections of your site nice and simple.</p>

<h2>The Explanation</h2>

<p>Often times, specific styling/formatting is shared between similar pages. The traditional way to deal with this is to include additional CSS files when special formatting is needed. I&#8217;ve found body classing to be more useful and more efficient.<sup><a href="#footnote-1-228" id="footnote-link-1-228" title="See the footnote.">1</a></sup></p>

<p>Since the pages that share styling often also share a path in the url, it&#8217;s really simple to add the path parts as classes to the body tag. For example, say the <strong><em>about</em></strong> section of a web site needs special formatting because it has an extra sidebar or maybe some sort of widget. I would add the class &#8216;about&#8217; to the body tag of all of the about pages. This method continues down the hierarchy. The page at <strong><em>/about/history</em></strong> would have a body class of &#8216;about history&#8217;, and so on. It&#8217;s very simple and very handy.</p>

<p>It&#8217;s also very simple to add this functionality to your layouts whether you&#8217;re using Rails or any other framework. My PHP framework, <a href="http://github.com/postpostmodern/phooey/tree">Phooey</a>, does it for you automatically.</p>

<p>For Rails, you can include this in your layout:</p>

<p><code>&lt;body class="&lt;%= controller_name -%&gt; &lt;%= action_name -%&gt;"&gt;</code></p>

<p>&#8230;or, if you&#8217;re using Haml (which I highly recommend):</p>

<p><code>%body{:class =&gt; "#{controller_name} #{action_name}"}</code></p>

<p>Agree? Disagree? Confused? Let me know down there in the comments.<br /></p>

<ol class="footnotes"><li id="footnote-1-228">I am of the opinion that you should only include <em>one CSS file per media type</em> in any page of your site (except for the IE stylesheets). I usually include only the following stylesheets in every page of every site: all.css, screen.css, print.css. And each one of those is minified. More on this in my forthcoming article on Sass.  <a href="#footnote-link-1-228">&#8593; back up there</a></li></ol>
]]></content:encoded>
			<wfw:commentRss>http://postpostmodern.com/instructional/a-body-with-class/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails Tip: Default Scope</title>
		<link>http://postpostmodern.com/instructional/rails-tip-default-scope/</link>
		<comments>http://postpostmodern.com/instructional/rails-tip-default-scope/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 16:27:30 +0000</pubDate>
		<dc:creator>Jason Johnson</dc:creator>
				<category><![CDATA[Instructional]]></category>
		<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[named_scope]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://postpostmodern.com/?p=221</guid>
		<description><![CDATA[An easy way to designate default options for find(:all)]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started using the <a href="http://www.railsbrain.com/api/rails-2.1.2/doc/index.html?a=M003687&#038;name=all"><strong>all</strong></a> method instead of <strong>find(:all)</strong> for fetching records – mainly because it&#8217;s shorter to type, but it&#8217;s also easy to override with a named scope. Just create a named_scope called <strong>all</strong> to set whatever default conditions and order you want. You can always use <strong>find(:all)</strong> if you want the non-scoped records.</p>

<pre><code lang="ruby">named_scope :all, { 
  :order => 'last_name',
  :conditions => 'activated_at IS NOT NULL'
}</code></pre>

<p>Thoughts, corrections and objections welcome in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://postpostmodern.com/instructional/rails-tip-default-scope/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Capistrano on Media Temple</title>
		<link>http://postpostmodern.com/instructional/a-recipe-for-capistrano-rails-deployment-on-media-temples-grid-server/</link>
		<comments>http://postpostmodern.com/instructional/a-recipe-for-capistrano-rails-deployment-on-media-temples-grid-server/#comments</comments>
		<pubDate>Thu, 30 Nov 2006 00:25:58 +0000</pubDate>
		<dc:creator>Jason Johnson</dc:creator>
				<category><![CDATA[Instructional]]></category>
		<category><![CDATA[Capistrano]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Media Temple]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.postpostmodern.com/2006/11/29/a-recipe-for-capistrano-rails-deployment-on-media-temples-grid-server/</guid>
		<description><![CDATA[A tutorial for deploying a Rails app on Media Temple's Grid Server using Capistrano]]></description>
			<content:encoded><![CDATA[<h2>[UPDATE 1/6/07]</h2>

<p>I had originally left out the step where you create the &#8216;rails&#8217; directory inside the container directory. I thought that the mtr add utility might do that automatically, but it doesn&#8217;t look it. So, make sure you do #8 of Step 1 if you&#8217;re starting from scratch.</p>

<h2>[UPDATE 12/1/06]</h2>

<p>When I first wrote this article, WordPress was converting my double hyphens to en dashes (like a hyphen/dash but longer). Consequently, copy/pasting the command line input didn&#8217;t work. Now, it should be fixed and copy/pasting the commands should work. When in doubt, re-type it.</p>

<p>&#8230;easy as pie! You could even call it a recipe for pie!</p>

<p>I had the pleasure of deploying a Rails site on Media Temple&#8217;s new Grid Server recently. I have to say, it&#8217;s probably the easiest set up I&#8217;ve used for Rails.</p>

<p>There are basically three simple steps to setting up and deploying once you have the account set up: installing the container and rails; configuring your Capistrano recipe; and deploying.</p>

<p>I have created <a href="http://blog.postpostmodern.com/download/mt-gs-deploy.rb.zip">my own deploy.rb recipe</a> which makes things even easier than the default <a href="http://gems.mediatemple.net/deploy.rb">MT recipe</a>.</p>

<h3>Step 1: Rails and the Container</h3>

<p>The following is mostly taken straight from MT&#8217;s Server Guide. The part that differs is in Step 2 and 3.</p>

<ol>
    <li>The first thing you need to do is enable ssh access for your server admin on your Grid Server account. That&#8217;s done via the Account Center control panel.</li>
    <li>Next, you need to activate the container. That&#8217;s also done via the control panel (under Ruby on Rails).</li>
    <li>SSH into your acocunt and set up your gems:
<kbd class="block">mtr  setup_rubygems -u serveradmin@domain.com -p</kbd></li>
    <li>Load your newly created environment variables:
<kbd class="block">source ~/.bash_profile</kbd></li>
    <li>Install Rails and dependencies:
<kbd class="block">gem install rails -y</kbd></li>
    <li>Install MySQL driver (postgres is also available):
<kbd class="block">gem install mysql --source=http://gems.mediatemple.net/</kbd></li>
    <li>Install Mongrel:
<kbd class="block">gem install daemons gem_plugin -y
gem install mongrel --source=http://gems.mediatemple.net/</kbd></li>
    <li>Create a rails directory:
<kbd class="block">mkdir ~/../../containers/rails</kbd></li>
</ol>

<p>Rails is pretty much ready for an app now.</p>

<h3>Step 2: Configuring your Application</h3>

<p>This is standard Capistrano procedure except for the specialized gem and deploy recipe.</p>

<p>[UPDATE] I should mention that the rest of this procedure takes place on your local (development) machine.</p>

<ol>
    <li>If you don&#8217;t have Capistrano installed, do it:
<kbd class="block">sudo gem install capistrano</kbd></li>
    <li>Install MT&#8217;s special Capistrano tasks (all one line):
<kbd class="block">sudo gem install mt-capistrano --source=http://gems.mediatemple.net/</kbd></li>
    <li>&#8220;Capistranize&#8221; your application by cd-ing into your rails root and running:
<kbd class="block">cap --apply-to ./ <var>YourApplicationName</var></kbd></li>
    <li>Download my <a href="http://blog.postpostmodern.com/download/mt-gs-deploy.rb.zip">Grid Server deployment recipe</a>, unzip it and use it to replace your default config/deploy.rb file.</li>
    <li>Open up the new deploy.rb in your favorite text editor and fill in the config info at the top.</li>
    <li>Check your app in to your svn repository.</li>
</ol>

<p>Now, your app is properly set up.</p>

<h3>Step 3: Deploy (the fun part)</h3>

<ol>
    <li>Set up the directory structure:
<kbd class="block">cap setup</kbd></li>
    <li>Do a &#8220;cold deploy&#8221;:
<kbd class="block">cap cold_deploy</kbd></li>
    <li>Visit your site, and revel in your overwhelming sense of accomplishment.</li>
</ol>

<h3>Disclaimer</h3>

<p>The above worked for me. Unless I&#8217;ve mis-documented something, it should work for you, but I can&#8217;t guarantee it. Please don&#8217;t blame me for any damage, and let me know if you find errors. I&#8217;ll do my best to address questions in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://postpostmodern.com/instructional/a-recipe-for-capistrano-rails-deployment-on-media-temples-grid-server/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Dog Days of an Indian Summer</title>
		<link>http://postpostmodern.com/editorial/dog-days-of-an-indian-summer/</link>
		<comments>http://postpostmodern.com/editorial/dog-days-of-an-indian-summer/#comments</comments>
		<pubDate>Tue, 08 Aug 2006 02:18:44 +0000</pubDate>
		<dc:creator>Jason Johnson</dc:creator>
				<category><![CDATA[Editorial]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Capistrano]]></category>
		<category><![CDATA[CRAM]]></category>
		<category><![CDATA[Mongrel]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.postpostmodern.com/2006/08/07/dog-days-of-an-indian-summer/</guid>
		<description><![CDATA[Take your Rails app and CRAM it up your server]]></description>
			<content:encoded><![CDATA[<p>&#8220;The future of Rails deployment belongs to <a href="http://mongrel.rubyforge.org/">Mongrel</a>,&#8221; <a href="http://railsconf.org/talks/selected/show/155">they said</a>.</p>

<p>So, about a month ago, not long after Lighty had settled into its little corner of the new server and was happily churning out web sites, I decided to shut it down. Lightttpd is a great web server, but my new CRAM setup feels so much better.</p>

<p>I&#8217;m talking about Capistrano, Rails, Apache, Mongrel. Coda Hale wrote <a href="http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/">a great article</a> on setting it up. I used his basic procedure, tailored it to my specific needs/personality, and voila! CRAM!</p>

<p>See, Apache + FastCGI was sketchy at best, but Apache + Mongrel seems to be delightful. Now that Apache&#8217;s back in the mix, it&#8217;s a lot easier to run my PHP-based sites (and sites that rely on .htaccess files) alongside my Rails apps. And, even though Apache 2.2 wasn&#8217;t my favorite thing to install (nor was it my least favorite), I&#8217;m feeling darn good about my decision. Not only have I had much success with CRAM so far, there&#8217;s plenty of evidence that the Mongrel will be around for a bit. Edge Rails now uses Mongrel by default, and it&#8217;ll even be a part of Leopard&#8217;s Rails setup.</p>

<p>Speaking of Rails in Leopard. Nothing surprised me more that <a href="http://weblog.rubyonrails.org/2006/8/7/ruby-on-rails-will-ship-with-os-x-10-5-leopard">that news</a>. I&#8217;m still a bit dumbfounded.</p>

<p>So, if you are developing in Rails and are trying to decide what sort of server stack/deployment you want to use, try CRAM.</p>
]]></content:encoded>
			<wfw:commentRss>http://postpostmodern.com/editorial/dog-days-of-an-indian-summer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
