<?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>Making it Personal</title>
	<atom:link href="http://accentuate.me/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://accentuate.me/blog</link>
	<description>The company blog of Accentuate.Me LLC</description>
	<lastBuildDate>Tue, 10 Aug 2010 23:29:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Why You Might Need an API</title>
		<link>http://accentuate.me/blog/?p=46</link>
		<comments>http://accentuate.me/blog/?p=46#comments</comments>
		<pubDate>Tue, 10 Aug 2010 20:59:46 +0000</pubDate>
		<dc:creator>Jeremy Nicoll</dc:creator>
				<category><![CDATA[Business / Marketing]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://accentuate.me/blog/?p=46</guid>
		<description><![CDATA[<a href="http://accentuate.me/blog/?p=46"><img align="left" hspace="5" width="150" src="/images/blog/plugged-in.jpg" class="alignleft wp-post-image tfe" alt="Audio cord plugged into the ground" title="" /></a>Copyright Accentuate.Me LLC Do you allow others to plug in to your architecture however they&#8217;d like? API stands for Application Programming Interface. Basically an API is a way for other people to write code to access your application or your &#8230; <a href="http://accentuate.me/blog/?p=46">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 250px; text-align: center; margin: 0 0 10px 10px; font-size: 80%;"><img src="/images/blog/plugged-in.jpg" alt="Audio cord plugged into the ground" width="240" height="167" /> Copyright Accentuate.Me LLC<br />
Do you allow others to plug in to your architecture however they&#8217;d like?</div>
<p>API stands for Application Programming Interface. Basically an API is a way for other people to write code to access your application or your website. The funny thing is that when I explain this to people they tend to immediately ask me: &#8220;Why would I want that??&#8221;. Well, let us start with a small website that exploded in popularity almost overnight: Twitter.</p>
<p>The idea of Twitter is very simple: post what you are doing in 140 characters or less. You can follow what others do, and they can follow what you do. Doesn&#8217;t sound like much, and really the idea is very simple. However, the implementation was much more than just that. One of the key features that contributed to the Twitter&#8217;s success was its ability for users to send messages however they liked: through the website, through text messaging, or by accessing the service through its API. <span id="more-46"></span> Many users do not access this API directly, rather they access it through applications written by other people which use the API. For example: I can access Twitter using an application on my desktop called Tweetie. Tweetie was not originally written by the Twitter team, but it keeps track of my accounts and I can check it much more easily and quickly than going to the website. I would probably not be using the services if I did not have this application.</p>
<p>If you have a website that directly provides a service, look into creating an interface for other programs to use it.  We get stuck in the mindset that we have to do all the work ourselves. Twitter currently has 70,000 registered applications. That&#8217;s not even counting the people using these applications. If you can make it easier for others to build on what you&#8217;ve done, you will get many more people using what you have to offer.</p>
<p>A good example of a company that needs an API is a print shop. Rather than do all the marketing themselves and force everyone to use the same piece of software or submit their orders manually, their website could be opened up to allow anyone to submit and manage their orders programmatically.  This way if someone wishes to build a different interface and make use of the print services, they can easily do it.</p>
<p>There is no absolute standard way to do an API, except whatever you or your developer decides. One way that is easy for potential partners to access an API is through the Internet and address based mappings. For example, after logging in an application could query your website by going to http://yourwebsite.com/orders.json and your website would respond with something like this:</p>
<pre><code>[
  {
    'order_id' : 'a384-321',
    'line_items' :  [ { 'item_id' : 'desk-01', 'description' : 'Sights of Maui (Desktop)', 'price' : 11.82, 'quantity' : 1 } ],
    'shipping_address'  :  { ... }
  }
]</code></pre>
<p>Such a thing might look a bit like nonsense to you, but this is in a format that programmers use to extend the functionality of your company. In the end, it means more customers using your services as people develop applications that interface with your service. Back to the print shop example: if you allow someone to build a website for photographers that automatically sends in orders to your print shop both you and the other website builder win. They get customers for their application, you get additional printing business.  It&#8217;s an easy way to get others working for you by making their lives easier as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://accentuate.me/blog/?feed=rss2&amp;p=46</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Exhaustive Guide to the Rails 3 Router</title>
		<link>http://accentuate.me/blog/?p=12</link>
		<comments>http://accentuate.me/blog/?p=12#comments</comments>
		<pubDate>Mon, 02 Aug 2010 23:05:07 +0000</pubDate>
		<dc:creator>Jeremy Nicoll</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://accentuate.me/blog/?p=12</guid>
		<description><![CDATA[<a href="http://accentuate.me/blog/?p=12"><img align="left" hspace="5" width="150" src="http://farm4.static.flickr.com/3398/3666001917_6e6e41da55_m.jpg" class="alignleft wp-post-image tfe" alt="Railroad Capital USA" title="" /></a>Rails 3 boasts a whole slew of improvements over the previous version, one of my favorite changes is... <a href="http://accentuate.me/blog/?p=12">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div style="float: left; width: 250px; text-align: center; margin: 0 10px 10px 0; font-size: 80%;"><a title="Railroad Capital USA by md11forever, on Flickr" href="http://www.flickr.com/photos/md11forever/3666001917/"><img src="http://farm4.static.flickr.com/3398/3666001917_6e6e41da55_m.jpg" alt="Railroad Capital USA" width="240" height="160" /></a> Photo Credit: md11forever on Flickr</div>
<p>Rails 3 boasts a whole slew of improvements over the previous version, one of my favorite changes is the way the new router works. It&#8217;s a lot like the Merb router, but builds on the ideas and adds all sorts of functionality and configurability that is not possible (or is a lot more painful) in Rails 2 or Merb. One thing you can do to learn about the functionality of the router is open up the source files. They are in the ruby gem ActionPack in the action_dispatch folder. This is what I have done as well as looked at what others have done. The documentation is quite good in the source files.  However, for those who do not wish to locate and read the source and read multiple blog posts, I thought it&#8217;d be fun to go through and thoroughly document the behaviors and give a overview of how they work.<br />
<span id="more-12"></span></p>
<h2>What Routes Do</h2>
<p>A route takes a URL (like http://accentuate.me/photography/albums/) and breaks it up into variables that can be more easily used by your application.  Rails uses a few special variables to decide where to send the request, namely <em>controller</em>, <em>action</em>, and <em>format</em>.  The use of the variable <em>id </em>is a standard way of specifying to your application what record needs to be retrieved on RESTful routes, but this is not used by Rails directly. The nice thing is that you can also define your own variables to match different parts of the URL.</p>
<h2>A Bit on REST</h2>
<p>Perhaps the biggest hangup that a beginning Rails programmer would encounter in routing is the use of REST. REST stands for &#8220;Representational State Transfer&#8221;, a title which doesn&#8217;t do much to explain its purpose to the uninitiated.  If you have spent any time making forms which post information to a backend script, you should already be familiar with two <em>verbs</em> that are used in online communication: <em>post </em>and <em>get</em>. At first you might assume that the only difference between these two methods is the way in which they send variables. <em>Get </em>requests send variables in the URL whilst <em>post </em>requests send them in the request body &#8211; at least that is what I thought at first.</p>
<p>It turns out that these two methods (also called verbs) are actually indications of what the program on the web server is supposed to do. I will be using the word verb instead of method for the rest of the article. There are more than just the two verbs that web browsers support. There is also <em>put</em> and <em>delete</em>.</p>
<ul>
<li><strong>Get:</strong> This verb is used simply to retrieve information on a resource. Getting a web page or other response is all that should generally happen with a <em>get</em> request. Design limitations at times will preclude this, but as a general rule <em>get </em>requests should not modify anything.</li>
<li><strong>Post</strong>: You use this verb to <em>make a new resource</em>. So any time you add a new record or create something, under RESTful design you should use the <em>post</em> verb.</li>
<li><strong>Put:</strong> When you wish to update information on a resource that has already been created, you use the <em>put </em>verb.</li>
<li><strong>Delete: </strong>This verb is used to delete or destroy information. An example would be deleting a row from a relational database.</li>
</ul>
<p>There is a slight problem when using REST for routing: most web browsers only support the <em>post</em> and <em>get </em>verbs. As such, Rails uses a workaround to signal to your application what method to actually use. It adds a _method variable to all forms with the the desired verb when you use the form helpers. So when you use the following code:</p>
<pre><code>&lt;%= form_for '/posts/3', :method =&gt; :put do %&gt;
&lt;!-- your form code goes here --&gt;
&lt;% end %&gt;</code></pre>
<p>It will look something like this:</p>
<pre>&lt;form action="/posts/3" method="post"&gt;
&lt;input name="_method" type="hidden" value="put" /&gt;
&lt;!-- your form code goes here --&gt;
&lt;/form&gt;</pre>
<p>The <em>post</em> verb is what matches the other unsupported verbs the closest in the way it is transmitted and so that is what is told to the browser whilst the real method is transmitted using a hidden form variable. If you are making requests via JavaScript you can make use of this _method variable as well.</p>
<p>Rails makes extensive use of RESTful principles in its router, and it is generally encouraged. You can also match URLs in other ways, however.</p>
<h2>Show Your Routes</h2>
<p>One of the most useful tricks to learn if you are just starting out with Rails is a command in your application: <code>rake routes</code>. In a terminal and in your rails app folder, type this command (<code>rake routes</code>) to get a listing of all the routes in your application. I use it on occasion when my routes aren&#8217;t working the way I think they ought.  It&#8217;s a bit hard to read at first, but is an indispensable tool. I can hardly wait until they add the route information to error pages like they do in the Merb framework, though.</p>
<h2>The Route File</h2>
<p>To get started in creating your routes, you need to edit the route file. This file is located at /your/app/folder/config/routes.rb. Of course, you will need to replace &#8220;/your/app/folder&#8221; with the location of your Rails application. The first thing you might notice on opening the file is that there&#8217;s not very much actual code. There are a lot of detailed comments that do a great job of getting you started, which will be covered here as well. You will want to put all code between the <code>YourAppName::Application.routes.draw do |map|</code> and the last <code>end</code> statements. Note that use of the <code>map</code> variable is not required anymore to match routes. It is included to assist those who prefer the older way of mapping routes. Your app will complain about the |map| variable being deprecated until you remove it. This backwards compatible feature will be eliminated in Rails 3.1 so it behooves you to learn the new way of routing.</p>
<h2>URL Matching</h2>
<p>URL matching is what lays at the heart of Rails routing. It enables you to specify a pattern that when matched allows you to take further actions. To make it easy, the method used to make a basic match is called <code>match</code>. There are different ways to define matching parameters based on different parameters and using other methods, but at the heart of each is the match method.</p>
<pre><code>match ':controller(/:action(/:id(.:format)))'</code></pre>
<p>This is an example that is generally <em>not</em> encouraged, especially if you are using a lot of resource based routes (which will be covered later). It does serve as a nice first example. You will take note of the variable names which are preceded by a colon. When a variable name is prefaced with colon, it means to match everything up until the next forward-slash. When the variable name is prefaced with an asterisk (*), it means to match all characters, which can be handy for passing full paths as a variable to your controllers.  Anything that is not prefaced with a colon or an asterisk is treated as a literal string. Anything that is surround by parentheses is optional. If it is present in the URL, the variable will be populated. Otherwise it will not be present or be nil.</p>
<pre><code>match '/assets/*path' =&gt; "gridfs#serve"</code></pre>
<p>Any path that includes <code>/assets/</code> at the beginning will match this route. I use this route to serve files from a MongoDB server. A typical path is <code>/assets/image/web/4c4f7be10190bd0f100001c0/thumb_9543.jpg</code>, the string &#8220;image/web/4c4f7be10190bd0f100001c0/thumb_9543.jpg&#8221; is assigned to the variable <code>path</code>.</p>
<pre><code>match '/*action' =&gt; 'pages'</code></pre>
<p>This code allows me to define a controller and then just create erb pages in its views folder. If I create a file in Rails.root/views/pages/websites/pricing.html.erb for example and then go to the path /websites/pricing in my application, it&#8217;ll pull up the page without a fuss (after I&#8217;ve created the Pages controller via <code>rails generate controller pages</code> on the command line).</p>
<h2>Modifying Match</h2>
<p>You can add constraints to routes if you have needs of formatting the URL in a certain way or if you only want to match if a certain subdomain is present. If you only need to add a constraint to one match, use the :constraints option.</p>
<pre><code>match ':controller(/:action(/:id))', :constrants =&gt; { :id =&gt; /\d+/ }</code></pre>
<p>This code will ensure that any URL that matches this route must have a variable of ID that only consists of numbers. Since regular expressions are used, you have a lot of flexibility in how they are formatted. The only potential downside is that if you don&#8217;t know how to use regular expressions they can be difficult to understand. If you are serious about programming professionally, learn regular expressions and don&#8217;t whine about it. It&#8217;ll save your bacon more times than you will ever be able to keep track. (What&#8217;s the deal with programmers and bacon anyway?)</p>
<p>To add parameters to a bunch of match methods at once, you will want to use the scope method. For the sake of simplicity, we&#8217;re going to use the example above again.</p>
<pre><code>scope(:constraints =&gt; { :id =&gt; /\d+/}) do
  match ':controller(/:action(/:id))'
end</code></pre>
<p>You will note that the constraints option has been moved to the scope method, which is passed a block and the match method is called inside this block. If you simply wanted to define conditions and no other scope options (covered later), use the conditions method:</p>
<pre><code>constraints :id =&gt; /\d+/ do
  match ':controller(/:action(/:id))'
end</code></pre>
<p>This is a shortcut method that does exactly what the preceding example does.</p>
<h2>Dispatching</h2>
<p>Now that we&#8217;ve covered the very basics of matching, it&#8217;s time to talk about dispatching. Dispatching is calling a controller or even another application with the parameters that we&#8217;ve extracted from the URL using matching. If routing to an controller in your application, you have a few different options.</p>
<pre><code>match "/people/:action', :controller =&gt; 'people' </code></pre>
<p>This routes to the people controller. Rails will read whatever is in the action variable and call that method in the controller instance. Like most other things, there is a shortcut for this as well:</p>
<pre><code>match "/people/:action" =&gt; "people"
# or, if you want to match both controller and action
match "/people/laugh_at" =&gt; "people#laugh_at"</code></pre>
<p>To provide a default variable value if none is supplied, first make that variable optional and then supply the value in the options.</p>
<pre><code>match "/people(/:action)", :controller =&gt; 'people', :action =&gt; 'laugh_at'</code></pre>
<p>Rails 3 has been reworked so that all controllers are basically Rack applications. Rack is a sort of framework for frameworks. I will talk about Rack another day, but you can use this knowledge to route to any sort of application or convention that also works with Rack.  Anything that responds to the method <code>call</code> can be a destination for your route. You can define a proc</p>
<pre>match '/hello(/*path)', :to =&gt; proc { |env| [200, {}, "Hello, ugly!"] }</pre>
<p>This will match any path after /hello/ to the proc. It is passed the raw environment variables (in env) that Rails gets from Rack, and returns a Rack compatible response (<code>[http_status, http_headers, response_body]</code>). If you don&#8217;t understand why, don&#8217;t try to overcomplicate it: Rack is designed to be ultra-simple and all that it requires from applications is that they return an array with those three variables.</p>
<p>Since all that is required is that the endpoint be Rack compatible, you can also include your Sinatra apps in your Rails routing setup if you have any.</p>
<pre><code>match "/hello(/*path)", :to =&gt; YourSinatraApp</code></pre>
<h2>Using Verbs</h2>
<p>Remember that little discussion we had about verbs before (<em>post, get, put, delete</em>)? Well, we&#8217;re going to use them now. Hopefully you&#8217;ve not forgotten about them. If you have then scroll back to the top and read it again. Don&#8217;t worry, I&#8217;ll still be waiting for you here when you&#8217;re finished.</p>
<p>To specify which verb is required when requesting a URL, use the :via option.  So to specify a <em>post </em>request to a controller/action on the root path (/):</p>
<pre><code>match '/' =&gt; 'pages#send_request', :via =&gt; :post</code></pre>
<p>Shortcut method</p>
<pre><code>post '/' =&gt; 'pages#send_request'</code></pre>
<p>The verb <em>post</em> can be substituted with <em>get</em>, <em>put</em>, and <em>delete</em>.</p>
<h2>Resources</h2>
<p>This is where all the interesting stuff with REST comes together. A resource is basically an idea of an object. So say you have a collection of images that you wish to display. In a very simple case, you would simply define this in your routes file:</p>
<pre><code>resources :images</code></pre>
<p>It doesn&#8217;t look like much, but essentially here&#8217;s what this code does:</p>
<pre><code>get '/images' =&gt; 'images#index'           # list all images
get '/images/:id' =&gt; 'images#show'        # show one image
get '/images/new' =&gt; 'images#new'         # get form to create image
post '/images' =&gt; 'images#create'         # create image
get '/images/:id/edit' =&gt; 'images#edit'   # get form to edit image
put '/images/:id' =&gt; 'images#update'      # update image
delete '/images/:id' =&gt; 'images#destroy'  # delete image</code></pre>
<p>As you can see (or might see after looking at it a few times), this sets up a whole lot of paths to list, show, create, update, and delete images. The only thing that you have to worry about is defining the methods in the Images controller that handle each of these methods &#8211; or at the very least defines the methods that you actually need.<br />
There are also times that you want resources in resources. Blog posts have comments, and a logical choice for the URL for comments on a blog post is: /posts/3/comments. To achieve such a thing in the router:</p>
<pre><code>resources :posts do
  resources :comments
end</code></pre>
<p>When resource routes are constructed in such a way, the manner in which parameters are passed to the controller change as you go deeper in the hierarchy.  For the path &#8220;/posts/3&#8243;, the router will pass { :controller =&gt; &#8216;posts&#8217;, :action =&gt; &#8216;show&#8217;, :id =&gt; 3} to Rails and your application. For the path &#8220;/posts/3/comments&#8221; it will pass { :controller =&gt; &#8216;comments&#8217;, :action =&gt; &#8216;index&#8217;, :post_id =&gt; &#8217;3&#8242;}. For the path &#8220;/posts/3/comments/25&#8243; it will pass { :controller =&gt; &#8216;comments&#8217;, :action =&gt; &#8216;show&#8217;, :post_id =&gt; &#8217;3&#8242;, :id =&gt; 25}.</p>
<p>Suppose you wanted to make resources for all of the replies to comments. This seems a bit convoluted to me, but this is just an example and not Real Life™.</p>
<pre><code>resources :posts do
  resources :comments do
    resources :replies
  end
end</code></pre>
<p>The path &#8220;/posts/3/comments/25/replies&#8221; would be routed to { :controller =&gt; &#8216;replies&#8217;, :action =&gt; &#8216;index&#8217;, :post_id =&gt; &#8217;3&#8242;, :comment_id =&gt; &#8217;25&#8242;}. Because it gets to be quite cumbersome, nesting resources below another nested resource is discouraged &#8211; but there are times when the complexity is justified.</p>
<h2>Modifying Resource Behavior</h2>
<p>To change which controller is used on a resource:</p>
<pre><code>resources :posts, :controller =&gt; 'thingy'</code></pre>
<p>This will now all route all of your posts URLs to the thingy controller, and anyone who inherits your code will hate you for life plus quite possibly hunt you down to beat you senseless. Please name and route your controllers in a somewhat obvious way for all of humanity&#8217;s sake.</p>
<p>To do custom matching on URLs in resources, there&#8217;s an extra step that you have to take. With resources there are two groups of matchers: <code>collection</code> and <code>member</code>. So with our <code>posts</code> resource, the index action would be considered part of the collection group, and the edit action part of the member group. A simple way to remember is if it requires the <code>:id</code> parameter, it&#8217;s a member function. Otherwise, it&#8217;s a group function.</p>
<pre><code>
# This works well for single custom actions
collection :posts do
  get :unpublished, :on =&gt; collection
  # For when you want to show a HTML delete page
  # instead of confirming via Javascript
  get :delete, :on =&gt; :member
end

# This works better for multiple actions
collection :posts do
  collection do
    get :unpublished
    # Contrived. Maybe you want a method to set an
    # arbitrary order?
    put :reorder
  end
  member do
    get :delete
  end
end
</code></pre>
<p>So the additional URLs will be matched: &#8220;/posts/unpublished&#8221; (<em>get</em>), &#8220;/posts/reorder&#8221;, (<em>put</em>), and &#8220;/posts/3/delete&#8221; (<em>get</em>)</p>
<h2>URL Generators</h2>
<p>Part of the router is taking URLs apart into variables that can be used by Rails and your application, but the other part is doing the reverse: taking variables and making them into a URL to send back to the requesting client. When you use the <code>resources</code> method, the names are generated automatically. When using the <code>match</code> method, you have to define the names yourself if you wish to use URL generators on that route.</p>
<pre><code>match '/posts/:id' =&gt; 'posts#show', :as =&gt; 'post'</code></pre>
<p>This will generate two methods in all of your controllers named <code>post_path</code> and <code>post_url</code>.  As you might infer, the _path suffix just returns the URL path whilst the _url suffix returns a full URL with hostname and port. You can call <code>post_path(post_object)</code> and Rails will attempt to infer the ID from the object that was passed. If you&#8217;d prefer to set the parameters yourself you could also call <code>post_path(:id =&gt; post_instance_object.id)</code> to generate the URL.  Anything extra passed in like <code>post_path(post_object, :msg =&gt; "Hello")</code> will generate this URL: &#8220;/posts/3?msg=Hello&#8221;</p>
<p>Using the post resources code we used in the Resources section, to get the URL for a specific comment you would call  <code>post_comment_path(post_object, comment_object)</code> or <code>post_comment_path(:post_id =&gt; post_object.id, :id =&gt; comment_object.id)</code>. if you don&#8217;t pass the required variables to a URL helper method, it will attempt to grab the variables from the parameters on the current route.</p>
<p>Personally I don&#8217;t like the way Rails clutters up the space with a bunch of helper methods, I prefer the Merb way of using two methods to access routes, though I would like different names: <code>path(:post_comment, post_object, comment_object)</code> and url(:post_comment, post_object, comment_object). Maybe if I whine about it enough they&#8217;ll put it in Rails 3.1 :).</p>
<h2>Constraining and Scoping Fun</h2>
<p>There are all sorts of ways in which you can use the constraints option. Here are a list of known ones</p>
<ul>
<li><strong>ip</strong> You can specify a match on IP address. :ip =&gt; /127.0.0.1/</li>
<li><strong>subdomain</strong> www.accentuate.me will match :subdomain =&gt; /www/</li>
<li>There are a ton more. I will be updating this article shortly with many more options once I test them out or people suggest them in the comments.</li>
</ul>
<p>There are a few other options you can use besides constraints as well.</p>
<ul>
<li><strong>path</strong> Prepend a path to the contained matchers</li>
<li><strong>module</strong> Useful for when your controllers are in modules such as Blog::PostsController</li>
<li><strong>name_path</strong> Prepend a string to the name of the helper methods.</li>
</ul>
<pre><code>scope(:path =&gt; 'blog', :module =&gt; 'blog', :name_path =&gt; 'blog') do
  resources :posts
end</code></pre>
<p>This will match &#8216;/blog/posts&#8217; to <code>{ :controller =&gt; 'blog/posts', :action =&gt; 'index'}</code> and will also create the helper of <code>blog_posts_path</code> for use in your controllers in constructing the URL.  A shortcut method for all that code is <code>namespace</code></p>
<pre><code>namespace 'blog' do
  resources :posts
end</code></pre>
<p><code> </code></p>
<h2>Conclusion</h2>
<p>90% of the time, you won&#8217;t need most of what you read here &#8211; but the beauty is that when you do have a special routing case that the new Rails router is flexible enough to meet just about any need.  Those of us who have crazy ideas about hooking up multiple applications in one ruby process or want to store route parameters in a database can now do so much more easily in Rails 3. Happy hacking!</p>
<h2>References</h2>
<p>Rails Dispatch: <a href="http://www.railsdispatch.com/posts/rails-routing">The Powerful New Rails Router</a></p>
<p>Yehuda Katz: <a href="http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/">The Rails 3 Router: Rack it Up</a></p>
<p>Wikipedia: <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer"> Representational State Transfer </a></p>
]]></content:encoded>
			<wfw:commentRss>http://accentuate.me/blog/?feed=rss2&amp;p=12</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quit Being Such a Cog</title>
		<link>http://accentuate.me/blog/?p=6</link>
		<comments>http://accentuate.me/blog/?p=6#comments</comments>
		<pubDate>Wed, 14 Jul 2010 21:19:27 +0000</pubDate>
		<dc:creator>Jeremy Nicoll</dc:creator>
				<category><![CDATA[Business / Marketing]]></category>

		<guid isPermaLink="false">http://accentuate.me/blog/?p=6</guid>
		<description><![CDATA[<a href="http://accentuate.me/blog/?p=6"><img align="left" hspace="5" width="150" src="http://farm1.static.flickr.com/31/89240945_096811eff8_o.jpg" class="alignleft wp-post-image tfe" alt="Cog" title="" /></a>Are you replaceable? Do you really want to be? <a href="http://accentuate.me/blog/?p=6">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div style="float: right; text-align: center; width: 250px; margin: 15px;"><img src="http://farm1.static.flickr.com/31/89240945_096811eff8_o.jpg" alt="Cog" width="250" height="187" /><br />
Photo Credit: <a href="http://www.flickr.com/photos/andyarmstrong/89240945/in/photostream/" target="_blank">Andy Armstrong</a></div>
<p>Have you ever seen a cog? It&#8217;s almost certain that you have if you&#8217;ve ever seen a bicycle. A cog is a piece of metal that works in tandem with other cogs to make things move.  With the advent of relatively modern manufacturing techniques, it became possible to change out these cogs if they ever became worn or damaged. It used to be (several decades ago) that if you purchased a device and a piece broke that you&#8217;d have to have someone custom make that piece for your device. Making interchangeable pieces was a brilliant idea when it first came to light, and it still is. Unfortunately it has become something we have taken for granted and have taken this idea into realms in which it does not belong.</p>
<p>Have you ever felt like a cog, like your boss or clients could replace you at any time and still get the same results? Most people do, as this is how most of us have been trained to be: follow the rules, do as you&#8217;re told, be predictable, be consistent.  Many of us have been trained to think that rewards are given by the people &#8220;in charge&#8221; and that if you do what they want then you&#8217;ll be happy and successful. However, this model has started to fall apart drastically in the past few years. <span id="more-6"></span>  As unemployment is at record levels, a nation of interchangeable people is finding out the truth that has been partially obscured by times of prosperity: that if you only conform to the rules and do as you&#8217;re told that you are replaceable. Anyone could do your job, and as such you&#8217;re not very valuable to anyone because there are <em>millions</em> of people out there <strong>just like you.</strong></p>
<p>I admit: there are still many companies that punish people who think outside of the parameters they&#8217;re given. Such punishments are often a price of success, though. Those who persist in exploring new concepts and trying new ideas will get some guff from those around them as new ideas tend to frighten people, especially those who have been trained to only go with that which has already proved successful.   The thought is that this provides security, but it is a security that is illusionary. When times get tough, people cut out the unnecessary things out of their lives and their businesses. If you do not provide anything new, are you providing anything of value? <em>Can your customers or your boss go to someone (or anyone) else to do the same things that you do? </em>If the answer is yes, you have little job security.</p>
<p>We are so worried about keeping a job and being &#8220;safe&#8221; that we often lose both. It seems like a contradiction, a paradox if you will, but to be safe you have to take risks. Pain is inevitable, how we experience it is our choice. In order to be needed by others we have to give from who we are and provide unique insights to the problems facing those around us. If you run a business, being ignored is death. If you just have a job, being ignored means stagnation or termination when the fat needs to be trimmed. What are you doing for your clients or your boss that makes you invaluable? If you don&#8217;t see it (or they don&#8217;t see it), you might be in a lot of trouble.</p>
]]></content:encoded>
			<wfw:commentRss>http://accentuate.me/blog/?feed=rss2&amp;p=6</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

