<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Routing Rails</title>
	<atom:link href="http://www.nullislove.com/2007/06/14/routing-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nullislove.com/2007/06/14/routing-rails/</link>
	<description>Code for Coders</description>
	<lastBuildDate>Sat, 31 Dec 2011 17:28:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<item>
		<title>By: sohdubom</title>
		<link>http://www.nullislove.com/2007/06/14/routing-rails/comment-page-1/#comment-1338</link>
		<dc:creator>sohdubom</dc:creator>
		<pubDate>Thu, 25 Dec 2008 11:55:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.nullislove.com/2007/06/14/routing-rails/#comment-1338</guid>
		<description>hi Kevin ... merry xmas ... :-) well, i&#039;m studying routes right know, began with simple and named routes and know starting restfull routes. as an experiment i decide to: rake routes , considering my routes.rb file has only: map.resources users. well, we all know the output, but based on this output the last 3 mappings which are: show(get), update(put) and destroy(delete):

user GET    /users/:id              {:action=&gt;&quot;show&quot;, :controller=&gt;&quot;users&quot;}
     PUT    /users/:id              {:action=&gt;&quot;update&quot;, :controller=&gt;&quot;users&quot;}
     DELETE /users/:id              {:action=&gt;&quot;destroy&quot;, :controller=&gt;&quot;users&quot;}

based on the output above i decided to write the equivalent routes in the routes.rb file in order to mimic what map.resources does. so we will have 7 routes. to simplify let&#039;s just consider here these last 3 routes. first, based on the output above, my conclusion is that i could use 3 routes with the same name: map.user and differentiate then with the :method symbol, being get, put and delete for each one of them ... so rails would know which one to use based on the :method

map.user  &#039;users/:id&#039;, ... , :method =&gt; :get
map.user  &#039;users/:id&#039;, ... , :method =&gt; :put
map.user  &#039;users/:id&#039;, ... , :method =&gt; :delete

well, that doesn&#039;t work ... if i click delete in the view then the show action will be triggered. my 2nd conclusion is that since i&#039;m not using map.resources and instead i&#039;m using named_routes, then the routing system will use the top-first rule

my doubt is, how  rails understand map.resources since the output from rake routes doesn&#039;t imply us to do something like:

map.user_show  &#039;users/:id&#039;, ... , :method =&gt; :get
map.user_update  &#039;users/:id&#039;, ... , :method =&gt; :put
map.user_delete  &#039;users/:id&#039;, ... , :method =&gt; :delete

plus if i named_route like the sample above, i don&#039;t need to specify which method to use, cause the routes are named. right?

then my 3rd conclusion is that rails should understand:

map.user  &#039;users/:id&#039;, ... , :method =&gt; :get
map.user  &#039;users/:id&#039;, ... , :method =&gt; :put
map.user  &#039;users/:id&#039;, ... , :method =&gt; :delete

based on the :method differentiation. i also did: :requirements =&gt; {:method =&gt; :delete} in routes.rb or user_path(user) in my view, but no success.

obs. my delete link_to code:
link_to &#039;delete&#039;,  user,  :confirm =&gt; &#039;Confirm delete?&#039;,  :method =&gt; :delete

i still haven&#039;t read david black&#039;s book, but i think map.resources does something else behind the curtains.</description>
		<content:encoded><![CDATA[<p>hi Kevin &#8230; merry xmas &#8230; <img src='http://www.nullislove.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  well, i&#8217;m studying routes right know, began with simple and named routes and know starting restfull routes. as an experiment i decide to: rake routes , considering my routes.rb file has only: map.resources users. well, we all know the output, but based on this output the last 3 mappings which are: show(get), update(put) and destroy(delete):</p>
<p>user GET    /users/:id              {:action=&gt;&#8221;show&#8221;, :controller=&gt;&#8221;users&#8221;}<br />
     PUT    /users/:id              {:action=&gt;&#8221;update&#8221;, :controller=&gt;&#8221;users&#8221;}<br />
     DELETE /users/:id              {:action=&gt;&#8221;destroy&#8221;, :controller=&gt;&#8221;users&#8221;}</p>
<p>based on the output above i decided to write the equivalent routes in the routes.rb file in order to mimic what map.resources does. so we will have 7 routes. to simplify let&#8217;s just consider here these last 3 routes. first, based on the output above, my conclusion is that i could use 3 routes with the same name: map.user and differentiate then with the :method symbol, being get, put and delete for each one of them &#8230; so rails would know which one to use based on the :method</p>
<p>map.user  &#8216;users/:id&#8217;, &#8230; , :method =&gt; :get<br />
map.user  &#8216;users/:id&#8217;, &#8230; , :method =&gt; :put<br />
map.user  &#8216;users/:id&#8217;, &#8230; , :method =&gt; :delete</p>
<p>well, that doesn&#8217;t work &#8230; if i click delete in the view then the show action will be triggered. my 2nd conclusion is that since i&#8217;m not using map.resources and instead i&#8217;m using named_routes, then the routing system will use the top-first rule</p>
<p>my doubt is, how  rails understand map.resources since the output from rake routes doesn&#8217;t imply us to do something like:</p>
<p>map.user_show  &#8216;users/:id&#8217;, &#8230; , :method =&gt; :get<br />
map.user_update  &#8216;users/:id&#8217;, &#8230; , :method =&gt; :put<br />
map.user_delete  &#8216;users/:id&#8217;, &#8230; , :method =&gt; :delete</p>
<p>plus if i named_route like the sample above, i don&#8217;t need to specify which method to use, cause the routes are named. right?</p>
<p>then my 3rd conclusion is that rails should understand:</p>
<p>map.user  &#8216;users/:id&#8217;, &#8230; , :method =&gt; :get<br />
map.user  &#8216;users/:id&#8217;, &#8230; , :method =&gt; :put<br />
map.user  &#8216;users/:id&#8217;, &#8230; , :method =&gt; :delete</p>
<p>based on the :method differentiation. i also did: :requirements =&gt; {:method =&gt; :delete} in routes.rb or user_path(user) in my view, but no success.</p>
<p>obs. my delete link_to code:<br />
link_to &#8216;delete&#8217;,  user,  :confirm =&gt; &#8216;Confirm delete?&#8217;,  :method =&gt; :delete</p>
<p>i still haven&#8217;t read david black&#8217;s book, but i think map.resources does something else behind the curtains.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Null is Love &#187; Blog Archive &#187; Catch-all Routes</title>
		<link>http://www.nullislove.com/2007/06/14/routing-rails/comment-page-1/#comment-290</link>
		<dc:creator>Null is Love &#187; Blog Archive &#187; Catch-all Routes</dc:creator>
		<pubDate>Mon, 18 Jun 2007 12:20:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.nullislove.com/2007/06/14/routing-rails/#comment-290</guid>
		<description>[...] week, I posted that David Black has released a guide to using and configuring routes in Ruby on Rails and [...]</description>
		<content:encoded><![CDATA[<p>[...] week, I posted that David Black has released a guide to using and configuring routes in Ruby on Rails and [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

