<?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>McKinney Station &#187; Web Applications</title>
	<atom:link href="http://www.mckinneystation.com/categories/web-applications/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mckinneystation.com</link>
	<description>Ruby on Rails web application development for Dallas/Fort Worth and all of North Texas.</description>
	<lastBuildDate>Wed, 02 Sep 2009 14:29:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>LESS, CSS Frameworks, and Rails</title>
		<link>http://www.mckinneystation.com/2009/09/02/less-css-frameworks-and-rails/</link>
		<comments>http://www.mckinneystation.com/2009/09/02/less-css-frameworks-and-rails/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 14:06:21 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/?p=118</guid>
		<description><![CDATA[I have been a fan of the CSS frameworks for a while now.  I started with YUI and now use Blueprint or 960.gs on a regular basis.  What I never liked about the frameworks was the need to add all of the extra classes to the HTML markup.  It seemed messy, wasn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I have been a fan of the CSS frameworks for a while now.  I started with <a href="http://developer.yahoo.com/yui/grids/">YUI</a> and now use <a href="http://www.blueprintcss.org/">Blueprint</a> or <a href="http://960.gs/">960.gs</a> on a regular basis.  What I never liked about the frameworks was the need to add all of the extra classes to the HTML markup.  It seemed messy, wasn&#8217;t <a href="http://en.wikipedia.org/wiki/Semantic_Web">semantic</a> (not that I am a fanatic about that), and made it harder to reuse partials in my Rails projects.</p>
<h2>CSS Improved</h2>
<p>For a while now there has been <a href="http://sass-lang.com/">SASS</a>, which allows you to <a href="http://lab.hamptoncatlin.com/play/with/sass">write CSS-like files that get translated into CSS</a>.  The advantage is that you can now use things like nested rules, variables, mixins, and more.  The markup is similar to CSS so the learning curve is minimal.  On top of that, there is <a href="http://compass-style.org/">Compass</a>, which adds some of the popular CSS frameworks as mixins.  Now it is easy to mixin the styles of the frameworks to your semantic classes in the CSS without adding all of the extra framework specific classes to your HTML markup.</p>
<p>What I did not like about SASS and Compass was the dependency on <a href="http://haml-lang.com/">HAML</a>.  I have tried to make the switch form ERB to HAML and I know that you can use SASS and Compass without using HAML in your templates.  But it always seemed like an extra unneeded dependency in my apps.</p>
<h2>Less CSS</h2>
<p>I recently came across <a href="http://lesscss.org/">LESS</a>, a Ruby gem similar to SASS.  The idea is that you can write <code>.less</code> files that are CSS-like and they will be translated into CSS.  The advantage, as I see it, is that you can use existing <code>.css</code> files as <code>.less</code> files since the syntax is so similar. In addition to the standard CSS syntax, you also get nested rules, variables, and mixins, just like SASS, but without the extra dependency.  You can also import other CSS files as-is, like the CSS frameworks, and mix those styles into your semantic styles.  This eliminates the need for Compass to provide the SASS-ified version of the framework.</p>
<p>The gem itself is not specific to Rails and can be used on any project.  You just need to run the LESS compiler to translate the <code>.less</code> file into a <code>.css</code> file.  There is a <a href="http://github.com/augustl/less-for-rails">Rails plugin</a> that make it easy to start using LESS in your Rails projects.</p>
<h2>LESS In Action</h2>
<p>So what does it all look like?  I will leave you with an example of how it all fits together.</p>
<pre><code>@import 'blueprint/screen.css';

#content {
  .container;
  .clearfix;
  #main {
    .column;
    .span-18;
  }
  #sidebar {
    .column;
    .span-6;
    .last;
  }
}

#footer {
  .container;
  text-align: center;
  font-size: .75em;
  color: #666;
}</code></pre>
<p>You can see more in my <a href="http://github.com/gdagley/basejumper">Basejumper, a starter Rails application</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2009/09/02/less-css-frameworks-and-rails/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rails respond_to Made It Too Easy</title>
		<link>http://www.mckinneystation.com/2009/07/13/rails-respond_to-made-it-too-easy/</link>
		<comments>http://www.mckinneystation.com/2009/07/13/rails-respond_to-made-it-too-easy/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 16:49:35 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[Entrepreneurial]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Web Applications]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/?p=111</guid>
		<description><![CDATA[I recently had a spike in traffic (1-2 visits/day to 30-40 visits/day) over at CatechizeMe.com.  Someone out on the internet came across it, found it useful, and linked to it.  Yay!
With this new traffic, came some new requests for features.  The first was a request for a Google Gadget.  I didn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a spike in traffic (1-2 visits/day to 30-40 visits/day) over at <a href="http://www.catechizeme.com">CatechizeMe.com</a>.  Someone out on the internet came across it, found it useful, and linked to it.  Yay!</p>
<p>With this new traffic, came some new requests for features.  The first was a request for a <a href="http://www.google.com/ig/directory">Google Gadget</a>.  I didn&#8217;t know much about what I needed to create a Gadget, but after <a href="http://code.google.com/apis/gadgets/index.html">looking it up</a> I realized I could use the <a href="http://www.catechizeme.com/resources/catechizeme-api">CatechizeMe API</a> that came automatically when I built the app.  With just a few lines of code, the Daily Question service was created and returning JSON data.  You gotta love it when things are this easy.</p>
<p>BEFORE:</p>
<pre>
<code>  def daily_question
    @question = @catechism.daily_question
    render :template =&gt; '/questions/show'
  end</code>
</pre>
<p>AFTER:</p>
<pre>
<code>  def daily_question
    @question = @catechism.daily_question
    respond_to do |wants|
      wants.html { render :template =&gt; '/questions/show' }
      wants.js { render_json @question.to_json }
    end
  end</code>
</pre>
<p>So now I get a <a href="http://www.catechizeme.com/catechisms/westminster_shorter_catechism/daily_question">daily catechism question from the CatechizeMe website</a> or via the Google Gadget using JSON:</p>
<p><script src="http://www.gmodules.com/ig/ifr?url=http://www.catechizeme.com/static/google_gadget.xml&amp;up_catechism=westminster_shorter_catechism&amp;synd=open&amp;w=320&amp;h=150&amp;title=CatechizeMe+%3A+Daily+Catechism&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2009/07/13/rails-respond_to-made-it-too-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basejumper &#8211; Yet Another Starter Application</title>
		<link>http://www.mckinneystation.com/2009/02/22/basejumper-yet-another-starter-application/</link>
		<comments>http://www.mckinneystation.com/2009/02/22/basejumper-yet-another-starter-application/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 02:37:06 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development Environment]]></category>
		<category><![CDATA[Entrepreneurial]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[microapps]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/?p=102</guid>
		<description><![CDATA[I do not hide the fact that I like to try out new ideas by building lots of little applications.  One thing I find myself doing is recreating many of the same pieces for each application.  So I finally gave in and built a default template for the way I like all of [...]]]></description>
			<content:encoded><![CDATA[<p>I do not hide the fact that I like to try out new ideas by <a href="/2008/06/03/microapps-encourage-hacking/">building lots of little applications</a>.  One thing I find myself doing is recreating many of the same pieces for each application.  So I finally gave in and built a default template for the way I like all of my applications to start.  There are <a href="http://www.railsinside.com/elsewhere/100-7-barebones-rails-apps-to-kick-start-your-development-process.html">other starter apps</a>, but this one is tailored to my idiosyncrasies.</p>
<p>You can find the project, Basejumper, at: <a href="http://github.com/gdagley/basejumper">http://github.com/gdagley/basejumper</a></p>
<h2>What is included?</h2>
<h3>Blueprint <span class="caps">CSS</span> (<a href="http://www.bluprintcss.org">http://www.bluprintcss.org</a>)</h3>
<p>Say what you will about <span class="caps">CSS</span> frameworks, but they make my life a lot easier.  From the website, it &#8220;gives you a solid <span class="caps">CSS</span> foundation to build your project on top of, with an easy-to-use grid, sensible typography, and even a stylesheet for printing.&#8221;  There are official plugins for the framework, like &#8220;buttons&#8221; and &#8220;link-icons&#8221;, and other user created ones, like silksprite (<a href="http://www.ajaxbestiary.com/Labs/SilkSprite">http://www.ajaxbestiary.com/Labs/SilkSprite</a>).</p>
<h3>Authlogic (<a href="http://github.com/binarylogic/authlogic">http://github.com/binarylogic/authlogic</a>)</h3>
<p>The way I think authentication should be done.  Instead of copying a lot of authentication logic (encrypting passwords, remember tokens, etc.) into your user model, it is kept in the gem and is easily updatable.  It has lots of configuration options to fit with your authentication needs and some <a href="http://www.binarylogic.com/2008/11/3/tutorial-authlogic-basic-setup">really</a> <a href="http://www.binarylogic.com/2008/11/16/tutorial-reset-passwords-with-authlogic">good</a> <a href="http://www.binarylogic.com/2008/11/21/tutorial-using-openid-with-authlogic">tutorials</a>.</p>
<p>In app/models/user.rb</p>
<pre><code>class User &lt; ActiveRecord::Base
  acts_as_authentic
end</code></pre>
<h3>Configatron (<a href="http://github.com/markbates/configatron">http://github.com/markbates/configatron</a>)</h3>
<p>This is great way to store application wide configuration and settings.  By adding an initializer to load the config.yml, you can access configuration anywhere in the app.</p>
<p>In config/initializers/load_config.rb:</p>
<pre><code>configatron.configure_from_yaml("config/config.yml", :hash =&gt; Rails.env)</code></pre>
<p>And in config/config.yml</p>
<pre><code>development: &amp;#38;local
    property1: value1
    property2: value2

test:
  &lt;&lt;: *local
  value2: test_value2

production:
  &lt;&lt;: *local
  value2: prod_value2</code></pre>
<h3>Searchlogic (<a href="http://github.com/binarylogic/searchlogic">http://github.com/binarylogic/searchlogic</a>)</h3>
<p>From the same folks who brought you Authlogic, there is Searchlogic.  You will always need pagination.  You may not think so now, but believe me, you will.  So just start out with it enabled.  What I really, really like about Searchlogic, is not just the pagination support, but how easy it makes building advanced search forms (including searching nested objects).  And again, there is a <a href="http://www.binarylogic.com/2008/9/7/tutorial-pagination-ordering-and-searching-with-searchlogic">great tutorial</a></p>
<h3>log-buddy (<a href="http://github.com/relevance/log_buddy">http://github.com/relevance/log_buddy</a>)</h3>
<p>For the lazy debugger in all of us. How many times have you typed:</p>
<pre><code>some_var = 'some_value'
logger.debug "some_var = #{some_var}" </code></pre>
<p>Now try this</p>
<pre><code>some_var = 'some_value'
d { some_var }</code></pre>
<p>which will log</p>
<pre><code>some_var = 'some_value'  </code></pre>
<h3>micronaut and micronaut-rails (<a href="http://github.com/spicycode/micronaut">http://github.com/spicycode/micronaut</a> and <a href="http://github.com/spicycode/micronaut-rails">http://github.com/spicycode/micronaut-rails</a>)</h3>
<p>It just makes more sense to me.  Like <a href="http://rspec.info/">RSpec</a>, only fewer calories.  micronaut is a <a href="http://en.wikipedia.org/wiki/Behavior_Driven_Development"><span class="caps">BDD</span></a> framework similar to RSpec.  In fact it uses all the same RSpec matchers, so there is not a new syntax to learn.  And it adds metadata to the loaded examples that is useful for deciding which tests to run, exclude, document, etc. or building additional tools for your example suite.</p>
<p>The application currently has examples (a.k.a. specs) for most of the existing code.  Adding new examples, should be quick and easy.  To see it all, start with <code>rake examples</code></p>
<h3>beholder treasure map (<a href="http://github.com/spicycode/beholder">http://github.com/spicycode/beholder</a>)</h3>
<p>I like continuous integration.  I <a href="http://www.thinkrelevance.com">work for a company</a> that <a href="http://www.runcoderun.com">likes continuous integration</a>.  Having continuous testing locally let&#8217;s me as soon as I break something.</p>
<p>beholder watches for files to change and then reruns the appropriate tests/specs/examples.  Now I don&#8217;t have an excuse for not running the example suite, because it is always running for me.</p>
<h3>active_form (<a href="http://github.com/nesquena/active_form">http://github.com/nesquena/active_form</a>)</h3>
<p>Easy ActiveRecord validations for non-AR models (for those Contact Us forms).</p>
<h3>comatose (<a href="http://github.com/darthapo/comatose">http://github.com/darthapo/comatose</a>)</h3>
<p>Inevitably, every project wants to be able to manage the &#8220;static&#8221; content on the site.  Comatose is a very simple <span class="caps">CMS</span> plugin.  Nothing fancy, but that is great for these small projects.  You can even style the admin interface to look more like your application (which I did), but the default styles could work just fine.  It is possible to use the content in Comatose as an entire page or a partial across many pages.  The app has a migration that creates some default pages and an example partial.</p>
<h3>active_scaffold (<a href="http://github.com/activescaffold/active_scaffold">http://github.com/activescaffold/active_scaffold</a>)</h3>
<p>Fastest way to build a super simple admin interface.  Or you could use it to build more complex admin.  It is really quite flexible with its search, <span class="caps">CRUD</span>, and the ability to customize.</p>
<h3>display_flash_helper (<a href="http://github.com/gdagley/display_flash_helper">http://github.com/gdagley/display_flash_helper</a>)</h3>
<p>Shameless use of my own plugin to display flash messages.  Nothing too fancy.</p>
<h3>exception_notification (<a href="http://github.com/rails/exception_notification">http://github.com/rails/exception_notification</a>)</h3>
<p>Because they happen and I want to know about them.</p>
<h3>pretty_buttons (<a href="http://github.com/relevance/pretty_buttons">http://github.com/relevance/pretty_buttons</a>)</h3>
<p><span class="caps">HTML</span> buttons shouldn&#8217;t have to look so bad.  This plugin plays nicely with Blueprint <span class="caps">CSS</span> buttons plugin, too</p>
<h3>semantic_form_builder (<a href="http://github.com/nesquena/semantic_form_builder">http://github.com/nesquena/semantic_form_builder</a>)</h3>
<p><span class="caps">HTML</span> forms made easier and semantic.  Also makes the forms easier to style.</p>
<h3>seo_helper (<a href="http://github.com/relevance/seo_helper">http://github.com/relevance/seo_helper</a>)</h3>
<p>A few useful helpers for <span class="caps">SEO</span> purposes.  Create page titles (h1) that match the html title (title), support for meta tags and easily add some breadcrumbs to each page.</p>
<h2>Conclusion</h2>
<p>Like I said before, it is tailored to they way I like things to start out.  You can fork it and change it.  I may not roll you changes back in, but that&#8217;s ok because now you have an starter app just the way you like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2009/02/22/basejumper-yet-another-starter-application/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adding an iPhone Interface to an Existing Rails Application</title>
		<link>http://www.mckinneystation.com/2009/02/20/adding-an-iphone-interface-to-an-existing-rails-application/</link>
		<comments>http://www.mckinneystation.com/2009/02/20/adding-an-iphone-interface-to-an-existing-rails-application/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 17:21:20 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Entrepreneurial]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iUI]]></category>
		<category><![CDATA[pagination]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/?p=95</guid>
		<description><![CDATA[I have been gradually adding new features to my StagingTracks.com website.  Really, it is a place where I can try out new things outside the office.  I have upgraded the UI to be a little cleaner by using the Blueprint CSS framework.  It was a easy way to normalize the CSS across [...]]]></description>
			<content:encoded><![CDATA[<p>I have been gradually adding new features to my <a href="/http://www.stagingtracks.com">StagingTracks.com</a> website.  Really, it is a place where I can try out new things outside the office.  I have upgraded the UI to be a little cleaner by using the <a href="http://www.blueprintcss.org">Blueprint <span class="caps">CSS</span> framework</a>.  It was a easy way to normalize the <span class="caps">CSS</span> across browsers and easily implement a column-based layout.  I also added <a href="http://twitter.com/stagingtracks">Twitter notifications</a> when new shops, clubs, and shows are added and reminders for upcoming shows each week.  Does the model railroading community really need all of this?  Probably not, but it helps me keep my skillz sharp.</p>
<h2>Finding Shops, Clubs, and Shows on your iPhone</h2>
<p><a href="http://www.stagingtracks.com/posts/getting_started">When I built StagingTracks a few years ago</a>, I did it because I was traveling and wanted to easily find the model railroading community wherever I was.  As it has grown over the past few years, so has technology.  While it was possible to navigate the StagingTracks website using a browser on the phone, it was not optimal.  Since this is my little sandbox for experimenting, I wanted to see how difficult it would be to add an optimized iPhone interface.</p>
<h2>Native app or Web app?</h2>
<p>I spend my daylight hours <a href="http://www.thinkrelevance.com">developing web applications for others</a>, so it made sense that I should reuse the infrastructure that I already had in place.  I didn&#8217;t want to learn iPhone <span class="caps">SDK</span> and all that is involved with that right now and I had recently come across the <a href="http://code.google.com/p/iui/">iUi javascript and css framework</a>.  iUI can give web applications a native iPhone application feel, so I just needed to see how to incorporate it into my &#8220;legacy&#8221; Rails application.</p>
<h2>Resources</h2>
<p>A quick Google search for iUI and Rails turned up Ben Smith&#8217;s excellent <a href="http://www.slashdotdash.net/2007/12/04/iphone-on-rails-creating-an-iphone-optimised-version-of-your-rails-site-using-iui-and-rails-2/">iPhone on Rails</a> article.</p>
<h3>iPhoney</h3>
<p>Reading through the article, I downloaded <a href="http://www.marketcircle.com/iphoney/">iPhoney</a> for quick testing without an iPhone.  Be sure to use the iPhone User Agent in the iPhoney menu.</p>
<h3>Local Subdomain for Testing</h3>
<p>I was going to serve the iPhone version from the subdomain iphone.stagingtracks.com, so I needed to setup something similar in my local development environment.  Fortunately, this was very easy with the <a href="http://github.com/bjeanes/ghost/tree/master">Ruby Ghost gem</a> found via Robby Russell&#8217;s <a href="http://www.robbyonrails.com/articles/2009/01/12/get-to-know-a-gem-ghost">Get to know a gem: Ghost</a>.</p>
<pre><code>sudo ghost add iphone.localhost.com</code></pre>
<p>We needed to add the .com so that the call to the request.subdomains will pick out the iphone portion.</p>
<h3>iUI Framework</h3>
<p>After downloading the iUI framework from the <a href="http://code.google.com/p/iui/">project site</a>, I moved everything into its rightful place.</p>
<pre>
<code>public
  - stylesheets
    - iui.css
  - javascripts
    - iui.js
  - images
    - iui
      - copy all of the .gif and .png files into here</code>
</pre>
<p>Because I moved the images into the <code>/images/iui</code> folder, I needed to update the image locations in the iUI css.  A quick find/replace and I was ready to go.</p>
<h2>Application changes</h2>
<p>I won&#8217;t go into all the details since <a href="http://www.slashdotdash.net/2007/12/04/iphone-on-rails-creating-an-iphone-optimised-version-of-your-rails-site-using-iui-and-rails-2/">Ben&#8217;s article</a> hit most of the high points.  Here are the few additional bits that I came across as I was adding my iPhone interface.</p>
<h3>Basic approach</h3>
<p>The basic approach to adding the iphone interface is to update the controller to render the iphone partial without the layout (since everything is <span class="caps">AJAX</span>) and then create an iphone template.</p>
<p>In posts_controller.rb change from:</p>
<pre><code>def show
  @post = Post.find(params[:id])
end  </code></pre>
<p>to</p>
<p><strong>UPDATE:</strong>: format.html should come before format.iphone.  For some reason it was working for browsers that were not IE.  Weird.</p>
<pre><code>def show
  @post = Post.find(params[:id])
  respond_to do |format|
    format.html
    format.iphone { render :layout =&gt; false }
  end
end  </code></pre>
<p>iphone template posts/show.iphone.erb:</p>
<pre><code>&lt;div class="panel" title="&lt;%= @post.title %&gt;" selected="true"&gt;
  &lt;h3&gt;&lt;%= @post.title %&gt;&lt;/h3&gt;
  &lt;%= render :partial =&gt; 'post.html.erb', :locals =&gt; {:post =&gt; @post} %&gt;
&lt;/div&gt;  </code></pre>
<h3>Search Button</h3>
<p>Since one of the more interesing features of StagingTracks is the ability to search for organizations near you, I wanted that to be prominent.  By adding a &#8220;button&#8221; link to the toolbar, it now shows up on every page.</p>
<p>In application.iphone.erb:</p>
<pre><code>&lt;div class="toolbar"&gt;
  &lt;h1 id="pageTitle"&gt;&lt;/h1&gt;
  <a id="backButton" class="button" href="#"></a>
  &lt;%= link_to "Search", search_path, :class =&gt; 'button' %&gt;
&lt;/div&gt;</code></pre>
<h3>Dynamically Growing Lists (a.k.a pagination)</h3>
<p>Since I already had paging in place for the blog posts, I wanted to be able to reuse that, if possible.  Turns out that was pretty easy to add as well.  I needed to separate the post_items into a separate partial so that I could return the next page of <code>&lt;li&gt;'s</code> to replace the &#8220;More news&#8230;&#8221; link (notice the target for the &#8220;More news&#8230;&#8221; link is &#8220;_replace&#8221;).</p>
<p>In posts/index.iphone.erb</p>
<pre><code>&lt;ul title="News" selected="true"&gt;
  &lt;%= render :partial =&gt; 'post_items', :locals =&gt; {:posts =&gt; @posts} %&gt;
&lt;/ul&gt;</code></pre>
<p>In posts/_post_items.iphone.erb</p>
<pre><code>&lt;% posts.each do |post| %&gt;
  &lt;li&gt;&lt;%= link_to post.title, post %&gt;&lt;/li&gt;
&lt;% end %&gt;
&lt;%= content_tag :li, link_to("More news...", posts_path(:page =&gt; posts.next_page), :target =&gt; "_replace") if posts.next_page %&gt;</code></pre>
<p>A quick change in the posts_controller.rb from:</p>
<pre><code>def index
  @posts = Post.latest.published.paginate :page =&gt; page, :order =&gt; 'published_at desc'
end</code></pre>
<p>to:</p>
<p><strong>UPDATE:</strong>: Same change to the ordering of format.html and  format.iphone.  </p>
<pre><code>def index
  @posts = Post.latest.published.paginate :page =&gt; page, :order =&gt; 'published_at desc'
  respond_to do |format|
    format.html
    format.iphone do
      if page == 1
          render :layout =&gt; false
        else
          render :layout =&gt; false, :partial =&gt; "post_items", :locals =&gt; {:posts =&gt; @posts}
      end
    end
  end
end</code></pre>
<h3>Styling Form Select Inputs</h3>
<p>My search form has a dropdown for choosing the country that you want to search.  By default, this did not look very nice.  Since it didn&#8217;t need a label, I just left it out in the form and added some additional <span class="caps">CSS</span>.</p>
<p>In search/index.iphone.erb</p>
<pre><code>&lt;% form_tag(search_path, :class =&gt; 'panel', :title =&gt; 'Search')  do %&gt;
  &lt;h2&gt;Find Local Shops, Clubs, and Shows&lt;/h2&gt;

  &lt;%= content_tag :p, flash[:error], :class =&gt; 'error' if flash[:error] %&gt;

  &lt;fieldset&gt;
    &lt;div class="row"&gt;
      &lt;%= country_select :search, :country, ['United States', 'Canada'], {} %&gt;
    &lt;/div&gt;  

    &lt;div class="row"&gt;
      &lt;label for='search_city'&gt;City&lt;/label&gt;
      &lt;input type="text" value="" name="search[city]" id="search_city"/&gt;
    &lt;/div&gt;

    &lt;div class="row"&gt;
      &lt;label for='search_state'&gt;State&lt;/label&gt;
      &lt;input type="text" value="" name="search[state]" id="search_state"/&gt;
    &lt;/div&gt;
  &lt;/fieldset&gt;
  &lt;%= link_to "Submit", "#", :class =&gt; 'whiteButton', :type =&gt; "submit" %&gt;
&lt;% end %&gt;</code></pre>
<p>And in my extra iphone.css (anything else that I needed to add to iui.css)</p>
<pre><code>.row &gt; select {
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    margin: 0;
    border: none;
    padding: 0;
    height: 42px;
    background: none;
    font-size: 16px;
    width: 100%;
}

.error {
  font-weight: bold;
  color: #8a1f11;
  margin-left: 14px;
}</code></pre>
<h2>Conclusion</h2>
<p>All told, I probably spent less than eight hours over a couple of nights adding a simple iPhone interface to my existing application.  I still want to look in to modifying the <span class="caps">CSS</span> more to have it look more like the regular StagingTracks website, but that can come later.  This was a fun little experiment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2009/02/20/adding-an-iphone-interface-to-an-existing-rails-application/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Deploying Sinatra Apps on Dreamhost</title>
		<link>http://www.mckinneystation.com/2008/10/09/deploying-sinatra-apps-on-dreamhost/</link>
		<comments>http://www.mckinneystation.com/2008/10/09/deploying-sinatra-apps-on-dreamhost/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 05:22:47 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[Dallas]]></category>
		<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[microapps]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/?p=86</guid>
		<description><![CDATA[So I LOVE creating small apps as a way of trying out new things.  The problem is that I rarely deploy them anywhere.  Many end up sitting in my /workspace directory until I decide I need to reclaim the space and probably won&#8217;t work on it ever again.
Recently, the Dallas Relevance folks have [...]]]></description>
			<content:encoded><![CDATA[<p>So I LOVE creating <a href="http://www.mckinneystation.com/2008/06/03/microapps-encourage-hacking/">small apps as a way of trying out new things</a>.  The problem is that I rarely deploy them anywhere.  Many end up sitting in my <code>/workspace</code> directory until I decide I need to reclaim the space and probably won&#8217;t work on it ever again.</p>
<p>Recently, the Dallas <a href="http://www.thinkrelevance.com">Relevance</a> folks have been meeting at Panera while we wait for our office space to materialize.  Most of the time everything works out nicely: free wifi, decent coffee, plenty of room to spread out.  But one thing that doesn&#8217;t work correctly while at Panera is <a href="http://tinyurl.com">tinyurl.com</a>.  For some reason, tinyurl is blocked by Panera filters.  This would be fine for most, but since my twitter friends insist on using tinyurl to post links in their tweets, it is annoying not being able to see what is going on.</p>
<h2>Microapp to the Rescue</h2>
<p>So I figured this would be an opportunity for simple little that let me enter the tinyurl, figure out where it was going to redirect to, and go ahead and redirect me there.  This way I am never accessing the evil tinyurl.com directly from the Panera network, but instead letting my little app do that for me.</p>
<p>The app was pretty easy to write.  I used <a href="http://github.com/bmizerany/sinatra">Sinatra</a> and created one &#8220;controller&#8221; and one &#8220;view&#8221;.  Within a few minutes, Sinatra had &#8220;taken the stage on port 4567&#8243; and my app was working.  Locally.</p>
<h2>Give the app a home</h2>
<p>The next challenge came when I tried to deploy it to my trusty <a href="http://www.dreamhost.com">Dreamhost</a> account.  I love Dreamhost for playing around with small apps.  You get <a href="http://dreamhost.com/hosting.html">unlimited domains,</a> they have <a href="http://dreamhost.com/hosting-panel.html">a pretty cool admin control panel</a>, and they support deploying Rails applications with <a href="http://www.modrails.com/">Passenger Phusion</a>.  And since <a href="http://www.modrails.com/documentation/Users%20guide.html#_deploying_a_rack_based_ruby_application">Passenger Phusion 2.0 supports Rack enabled Ruby apps</a>, I knew I should be able to deploy this new app to my Dreamhost account.  A quick search turned up a useful post with <a href="http://www.gittr.com/index.php/archive/deploying-rack-apps-on-dreamhost-via-passenger-including-sinatra/">information on deploying to Sinatra apps on Dreamhost</a>.  Unfortunately, the first attempt didn&#8217;t work.</p>
<h2>Always check the logs</h2>
<p>So I went to the logs to see what went wrong&#8230; wait there weren&#8217;t any logs!  Fortunately I found this post for <a href="http://www.gittr.com/index.php/archive/logging-with-sinatra-and-passenger-another-try/">logging with Sinatra apps</a>.  Unfortunately, the logs didn&#8217;t help.  Apparently, my problem ran deeper.  So like all good debuggers, I started commenting out code and printing out where I was in the app.  The first thing I commented out was the called to render the view using ERB.  Turns out you can configure where the root of the app is located.  Apparently the root path for a Sinatra app running on Dreamhost is not exactly the path where you deployed it.  <code>Sinatra::Application.default_options[:root]</code> looked like this: </p>
<pre><code>/home/.machinename/username/app.domain.com/Rack: /home/.machinename/username</code></pre>
<h2>Additional configuration needed</h2>
<p>Looking through the Sinatra source turned up the needed configuration changes need:</p>
<pre><code>path = "/path/to/app"

Sinatra::Application.default_options.merge!(
  :root =&gt; path,
  :views =&gt; path + '/views',
  :public =&gt; path + '/public',
  :run =&gt; false,
  :env =&gt; :production
)</code></pre>
<p>A quick deploy later and the application was up and running.  Tomorrow we are meeting at Panera and I will get to see what everyone is tweeting about.</p>
<h2>Addendum: Deployment too?</h2>
<p>Since Sinatra apps are so small, you could just copy everything up to the server manually.  But I like have a little Rake task to do that for me.  It just touches the <code>tmp/restart.txt</code> that Passenger uses to know when to restart and then uses rsync to copy the files up to the server.</p>
<pre><code>desc 'Deploy to the server using rsync'
task :restart do
  sh "touch tmp/restart.txt"
end

desc 'Deploy to the server using rsync'
task :deploy =&gt; :restart do
  cmd = "rsync -ruv * #{USERNAME}@#{DOMAIN}:#{DEPLOY_PATH}"
  sh cmd
end</code></pre>
<h2>Take a look at the code</h2>
<p>I have <a href="http://github.com/gdagley/panera">posted the code on Github</a> for everyone to take a look at.  Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2008/10/09/deploying-sinatra-apps-on-dreamhost/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Google Charts with Rails</title>
		<link>http://www.mckinneystation.com/2008/08/22/using-google-charts-with-rails/</link>
		<comments>http://www.mckinneystation.com/2008/08/22/using-google-charts-with-rails/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 18:10:11 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[googlecharts]]></category>
		<category><![CDATA[microapps]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/?p=85</guid>
		<description><![CDATA[With one of my recent microapps, UnscientificPolls.com, I wanted to show the polling data in more interesting ways than just the vote counts.  Charting was the logical conclusion, but how do it was a more difficult decision.
Some of the criteria I had for choosing the charting solution included: ease of use (it is  [...]]]></description>
			<content:encoded><![CDATA[<p>With one of my recent <a href="/2008/06/03/microapps-encourage-hacking/">microapps</a>, <a href="http://www.unscientificpolls.com">UnscientificPolls.com</a>, I wanted to show the polling data in more interesting ways than just the vote counts.  Charting was the logical conclusion, but how do it was a more difficult decision.</p>
<p>Some of the criteria I had for choosing the charting solution included: ease of use (it is  microapp, of course), compatible with shared hosting environment, fast, easy to customize.</p>
<p>Some of the libraries I looked at included: <a href="http://code.google.com/p/flot/">flot with jquery</a>, <a href="http://nubyonrails.com/pages/gruff">gruff</a>, <a href="http://scruffy.rubyforge.org/">scruffy</a>, <a href="http://nubyonrails.com/pages/sparklines">sparklines</a>, and <a href="http://googlecharts.rubyforge.org/">googlecharts</a>.  I settled on the googlecharts library because I didn&#8217;t need the interactive features of <code>flot</code> and I didn&#8217;t want to worry about RMagick needed for <code>gruff</code>, <code>scruffy</code>, or <code>sparklines</code>. </p>
<h2>Google Charts API</h2>
<p>The <a href="http://code.google.com/apis/chart">Google Charts API</a> is an interesting tool that lets you dynamically generate charts using a &#8220;simple&#8221; URL scheme.   The usage policy is very generous too: &#8220;There&#8217;s no limit to the number of calls per day you can make to the Google Chart API.&#8221;</p>
<p>This would allow me to offload the image generation to Google (who supposedly has quite a bit of computing power) and let my application, in a shared hosting environment, focus on collecting votes.</p>
<h2>Enter <em>googlecharts</em></h2>
<p>The challenge with the Google Charts API &#8220;simple&#8221; url scheme is that it would very tedious to have generate it by concatenating the strings together.  Fortunately, Matt Aimonetti built the <code>googlecharts</code> gem for Ruby.  You can get it from <a href="http://www.rubyforge.org">Rubyforge</a> (<code>gem install googlecharts</code>) or <a href="http://www.github.com">Github</a> (<code>gem install mattetti-googlecharts</code>).  </p>
<h2>Installing <em>googlecharts</em> in my Rails App</h2>
<p>With <code>googlecharts</code> installed on my machine I could start using it, by adding it to my <code>config/environment.rb</code> file.</p>
<pre><code>Rails::Initializer.run do |config|
  config.gem "googlecharts", :lib =&gt; "gchart"
end</code></pre>
<p>Since the file we need to include is named &#8220;gchart&#8221;, not &#8220;googlecharts&#8221;, we have to specify the <code>:lib =&gt; "gchart"</code> option.</p>
<p>I also didn&#8217;t want to worry about installing in on the deployment machine, so I unpacked it to the <code>vendor/gems</code> folder using <code>rake gems:unpack</code>.</p>
<h2>Now to the Charts</h2>
<p>Once all that was in place the challenge was getting the data into a format that would be easy to pass to the library.  It turns out, that wasn&#8217;t too challenging either.</p>
<h3>The Helper</h3>
<p>In my view helper module I created a method that would collect the data needed for the chart.</p>
<pre><code>  def pie_chart poll
    @pie_chart ||= {
      :data =&gt; poll.choices.collect(&amp;:votes_count),
      :colors =&gt; poll.choices.collect {|c| c.winner? ? "264409" : "8A1F11" }
    }
  end</code></pre>
<p>This just loops over the choices and collects the needed data and puts it in an easy to use Hash.</p>
<h3>The View</h3>
<pre><code>    &lt;%= Gchart.pie :size =&gt; '240x160',
                   :title =&gt; 'Vote split',
                   :data =&gt; pie_chart(@poll)[:data],
                   :bar_colors =&gt; pie_chart(@poll)[:colors],
                   :format =&gt; 'image_tag' %&gt;</code></pre>
<p>Using googlecharts Gchart made it easy to build the &#8220;simple&#8221; url needed for a pie chart using the Google Charts API (also supports line, scatter, venn, sparklines, and meter charts)  I didn&#8217;t even have to add the <img /> tag because I could pass the <code>:format =&gt; 'image_tag'</code> and one was generated for me.</p>
<h2>Conclusion</h2>
<p>I was extremely happy with how quick and easy it was to get some simple charts into my application (check them out at <a href="http://www.unscientificpolls.com">UnscientificPolls.com</a>).  The response time from Google seems to be as fast as if the images were stored locally. It also saved me the headache of installing with RMagick.  This is definitely a good fit for simple graphs and charts in a Rails application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2008/08/22/using-google-charts-with-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS Mockups for Ads</title>
		<link>http://www.mckinneystation.com/2008/08/15/css-mockups-for-ads/</link>
		<comments>http://www.mckinneystation.com/2008/08/15/css-mockups-for-ads/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 21:43:10 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[microapps]]></category>
		<category><![CDATA[wireframing]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/?p=84</guid>
		<description><![CDATA[Occasionally I need to mockup where the ads are going to go in an application (it has to pay for itself somehow, right?).  Rather than putting the ads into the application while I am still doing development, I use some simple CSS to put a placeholder where the ads will go.  In Rails, [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally I need to mockup where the ads are going to go in an application (it has to pay for itself somehow, right?).  Rather than putting the ads into the application while I am still doing development, I use some simple CSS to put a placeholder where the ads will go.  In Rails, it looks like this:</p>
<pre><code>&lt;div class="ads vertical_tower"&gt;
  &lt;% if RAILS_ENV == 'production' -%&gt;
    &lt;script&gt;... Live Ad Code Goes Here &lt;/script&gt;
  &lt;% else -%&gt;
    Ads Go Here
  &lt;% end -%&gt;
&lt;/div&gt;</code></pre>
<p>Then I can use my simple <a href="http://www.mckinneystation.com/ad_templates/index.html">ad template CSS</a> to make it standout.  Check out <a href="http://github.com/gdagley/ad_templates">the css source on Github</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2008/08/15/css-mockups-for-ads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microapps Encourage Hacking</title>
		<link>http://www.mckinneystation.com/2008/06/03/microapps-encourage-hacking/</link>
		<comments>http://www.mckinneystation.com/2008/06/03/microapps-encourage-hacking/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 14:54:46 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[RailsConf]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[SliceHost]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[microapps]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/2008/06/03/microapps-encourage-hacking/</guid>
		<description><![CDATA[photo by Jeff Belmonte
I am back from RailsConf 2008 and two of my favorite talks were &#8220;Microapps for Fun and Profit&#8221; by Erik Kastner and &#8220;23 Hacks&#8221; by Nathaniel Talbott.  I have recently been toying around with creating small little apps where I can try out new ideas and sharpen my skills.  
One [...]]]></description>
			<content:encoded><![CDATA[<div class="shadow left"><img src='http://www.mckinneystation.com/wp-content/uploads/2008/06/small_train.jpg' alt='Small Train' /><br/><span class="credit">photo by <a href="http://www.flickr.com/photos/jeffbelmonte/">Jeff Belmonte</a></span></div>
<p>I am back from <a href="http://www.railsconf.com">RailsConf 2008</a> and two of my favorite talks were &#8220;<a href="http://metaatem.net/2008/05/30/my-railsconf-talk">Microapps for Fun and Profit</a>&#8221; by <a href="http://metaatem.net/">Erik Kastner</a> and &#8220;<a href="http://blog.talbott.ws/articles/2008/5/31/23-hacks-railsconf-2008">23 Hacks</a>&#8221; by <a href="http://blog.talbott.ws/">Nathaniel Talbott</a>.  I have recently been toying around with creating small little apps where I can try out new ideas and sharpen my skills.  </p>
<p>One of those apps is the <a href="http://www.templategeneratorpro.com">Template Generator Pro</a>.  It was a really simple little app the generates funny <a href="http://coverletters.templategeneratorpro.com">cover letters</a>, <a href="http://twoweeknotice.templategeneratorpro.com">two week notices</a>, <a href="http://jobs.templategeneratorpro.com">job postings</a>, and more.  Not a lot to it.  What did I learn?  I deployed it to <a href="http://www.slicehost.com">SliceHost</a> (my previous apps have been deployed to <a href="http://dreamhost.com/">DreamHost</a>) and starting learning more about hosting and system administration.  I also had a chance to port the <a href="http://nonsense.sourceforge.net/">Nonsense Perl script</a> to <a href="http://nonsense.rubyforge.org/">a Ruby version</a>.  That was fun!</p>
<h2>Tools of the Trade</h2>
<p>What am I using for my microapps?  The first ones (<a href="http://www.catechizeme.com">CathechizeMe</a> and <a href="http://www.templategeneratorpro.com">TemplateGeneratorPro</a>) were small Rails applications.  But that is alot of overhead and not a lot of &#8220;micro&#8221; in that.  So for new things I am looking at <a href="http://sinatrarb.com/">Sinatra</a> for a framework and <a href="http://stone.rubyforge.org/">Stone</a> or <a href="http://ar.rubyonrails.com/">ActiveRecord</a> with <a href="http://www.sqlite.org/">SQLite</a> for persistance.  I like <a href="http://jquery.com/">JQuery</a> for the Javascript and <a href="http://code.google.com/p/blueprintcss/">BluePrint CSS</a> helps me make it look pretty fairly easily.  <a href="http://www.oswd.org/">Open Source Web Design</a> and <a href="http://www.openwebdesign.org">Open Web Design</a> help to stimulate the creative aspects of the designs.</p>
<h2>Check it Out</h2>
<p>You can see some my little hacks being stored on my GitHub account:  <a href="http://www.github.com/gdagley">http://www.github.com/gdagley</a>. I also have some projects from <a href="http://www.thinkrelevance.com">work</a> at <a href="http://www.github.com/relevance">http://www.github.com/relevance</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2008/06/03/microapps-encourage-hacking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RESTful Rails and Dreamhost</title>
		<link>http://www.mckinneystation.com/2007/12/17/restful-rails-and-dreamhost/</link>
		<comments>http://www.mckinneystation.com/2007/12/17/restful-rails-and-dreamhost/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 17:33:03 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[RSpec]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/2007/12/17/restful-rails-and-dreamhost/</guid>
		<description><![CDATA[photo by woodleywonderworks

I recently upgraded StagingTracks.com to use Rails 2.0.  I was excited about so many of the newest features that it seemed the logical thing to do.  I even decided to upgrade RSpec in the process so I would be able to play with some of the new features there too.  [...]]]></description>
			<content:encoded><![CDATA[<div class="shadow right"><img src='http://www.mckinneystation.com/wp-content/uploads/2007/12/train_wreck.jpg' alt='Train Wreck' /><br/><span class="credit">photo by <a href="http://flickr.com/photos/wwworks/">woodleywonderworks</a><br />
</span></div>
<p>I recently upgraded <a href="http://www.stagingtracks.com">StagingTracks.com</a> to use <a href="http://weblog.rubyonrails.com/2007/12/7/rails-2-0-it-s-done">Rails 2.0</a>.  I was excited about so many of the newest features that it seemed the logical thing to do.  I even decided to upgrade <a href="http://rspec.rubyforge.org">RSpec</a> in the process so I would be able to play with <a href="http://blog.davidchelimsky.net/articles/2007/12/14/rspec-1-1">some of the new features</a> there too.  </p>
<p>Unfortunately, despite extensive local spec&#8217;ing, when I <a href="http://capify.org/">deployed the app</a> to Dreamhost, <a href="http://www.stagingtracks.com/posts/view/a_minor_glitch">things did not go as planned</a>.  I was using <a href="http://piston.rubyforge.org/">piston to manage my Rails in the app and all of my plugins</a>, so I didn&#8217;t need to worry about which gems were installed on the server.  What I found was that when users tried to submit new information using the forms on the site, nothing would happen.  Let me correct that: It would look like something happened, but no data was submitted.</p>
<h2>So what was the problem?</h2>
<p>I first started by watching the <code>production.log</code> to see if the data was even getting submitted.  As expected, nothing was coming through.  I then used the <a href="https://addons.mozilla.org/firefox/addon/966">Tamper Data plugin</a> for Firefox to see if I if the data was getting out of the browser.  It was, but something interesting appeared.  I saw a 301 Redirect when the page was submitted.  Odd.  Especially since the application wasn&#8217;t seeing the data and there were no redirects in the production.log.  </p>
<p>So I started looking in the http <code>access.log</code> to see why the data wasn&#8217;t coming through to the app.  What I saw was surprising:</p>
<pre>
<code>- - [16/Dec/2007:19:24:30 -0800] "POST /shops HTTP/1.1" 301 591 "http://www.stagingtracks.com/shops/new" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
- - [16/Dec/2007:19:24:30 -0800] "GET /shops/ HTTP/1.1" 200 319 "http://www.stagingtracks.com/shops/new" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"</code></pre>
<p>It looked like the POST (which goes to the &#8216;create&#8217; method using Rails RESTful approach) was being redirected to &#8216;/shops/&#8217;.  The browser would then call &#8216;/shops/ &#8216; with a GET (which is the &#8216;index&#8217; action).  And the form submission never got through.  Now I was perplexed.  Why would the web server being sending the 301 Redirect?</p>
<p>It became a little clearer when I saw this in the logs as well:</p>
<pre>
<code>- - [16/Dec/2007:19:15:11 -0800] "GET /shops HTTP/1.1" 301 591 "http://www.stagingtracks.com/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
- - [16/Dec/2007:19:15:11 -0800] "GET /shops/ HTTP/1.1" 200 89174 "http://www.stagingtracks.com/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"</code></pre>
<p>For some reason, the web server was causing 301 Redirects when the trailing slash was missing!  Now I had heard of <a href="http://www.google.com/search?q=trailing+slash+rails">the trailing slash problem</a>, but couldn&#8217;t find a suitable solution that would be easy to implement.</p>
<h2>So How Do You Fix It?</h2>
<p>I am so glad I am surrounded by lots of smart people.  A quick conversation with my friend <a href="http://robsanheim.com/">Rob Sanheim</a> turned up <a href="http://mephisto.stikipad.com/help/show/Developer+Tips">the solution</a>.  </p>
<p>I added the following to my <code>.htaccess</code> file:</p>
<pre>
<code>DirectorySlash Off</code>
</pre>
<p>I added it after the <code>Options +FollowSymLinks +ExecCGI</code> and before the <code>RewriteEngine On</code></p>
<p>Now things are back to normal again.  I am now able to get back to <a href="http://www.stagingtracks.com">connecting model railroaders</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2007/12/17/restful-rails-and-dreamhost/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pay For What You Use</title>
		<link>http://www.mckinneystation.com/2007/12/01/pay-for-what-you-use/</link>
		<comments>http://www.mckinneystation.com/2007/12/01/pay-for-what-you-use/#comments</comments>
		<pubDate>Sun, 02 Dec 2007 04:44:52 +0000</pubDate>
		<dc:creator>Geoffrey</dc:creator>
				<category><![CDATA[Dallas]]></category>
		<category><![CDATA[Entrepreneurial]]></category>
		<category><![CDATA[North Texas]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Applications]]></category>

		<guid isPermaLink="false">http://www.mckinneystation.com/2007/12/01/pay-for-what-you-use/</guid>
		<description><![CDATA[My friend, Chris Gay, is a finalist in the Amazon Web Services Startup Challenge with his company, MileMeter.  I love the concept of only paying for the auto insurance I am going to use.  Both my wife and I work out of the home and therefore our cars sit in the garage alot. [...]]]></description>
			<content:encoded><![CDATA[<p>My friend, Chris Gay, is a finalist in the <a href="http://developer.amazonwebservices.com/connect/amazon_startupchallenge.jsp">Amazon Web Services Startup Challenge</a> with his company, <a href="http://www.milemeter.com">MileMeter</a>.  I love the concept of only paying for the auto insurance I am going to use.  Both my wife and I work out of the home and therefore our cars sit in the garage alot.  But I still have to pay the same rates as my neighbors who drive to downtown Dallas everyday.  For both cars!  </p>
<p>So now I urge you to <a href="http://developer.amazonwebservices.com/connect/amazon_startupchallenge.jsp">go and vote for Chris and MileMeter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mckinneystation.com/2007/12/01/pay-for-what-you-use/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
