<?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: Simply RESTful&#8230; &#8220;The missing action&#8221;</title>
	<atom:link href="http://thelucid.com/2006/07/26/simply-restful-the-missing-action/feed/" rel="self" type="application/rss+xml" />
	<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/</link>
	<description>Lightweight ramblings</description>
	<lastBuildDate>Mon, 22 Feb 2010 16:12:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tristan</title>
		<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/comment-page-1/#comment-2066</link>
		<dc:creator>Tristan</dc:creator>
		<pubDate>Fri, 04 Aug 2006 15:01:45 +0000</pubDate>
		<guid isPermaLink="false">16ea7a6c-c6c2-44bd-8c9c-aea8267f8ad7#comment-2066</guid>
		<description>I have never tried to submit a ticket.</description>
		<content:encoded><![CDATA[<p>I have never tried to submit a ticket.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie</title>
		<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/comment-page-1/#comment-2064</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Thu, 03 Aug 2006 21:55:26 +0000</pubDate>
		<guid isPermaLink="false">16ea7a6c-c6c2-44bd-8c9c-aea8267f8ad7#comment-2064</guid>
		<description>Tristan: &quot;Stop worrying and learn to love the delete&quot; ;)

Have you had any luck submitting tickets to Rails Trac site? I keep getting an error.</description>
		<content:encoded><![CDATA[<p>Tristan: &#8220;Stop worrying and learn to love the delete&#8221; <img src='http://thelucid.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Have you had any luck submitting tickets to Rails Trac site? I keep getting an error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tristan</title>
		<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/comment-page-1/#comment-2063</link>
		<dc:creator>Tristan</dc:creator>
		<pubDate>Thu, 03 Aug 2006 21:32:59 +0000</pubDate>
		<guid isPermaLink="false">16ea7a6c-c6c2-44bd-8c9c-aea8267f8ad7#comment-2063</guid>
		<description>I guess I was just looking for an excuse to make a hack. That or the fact that I&#039;ve only had 6 hours of sleep in the past 41 hours. I see what your getting at with the other actions, and for some reason it only makes sense now that you pointed it out. I think I&#039;ll go to sleep before I write more useless modifications for Rails.</description>
		<content:encoded><![CDATA[<p>I guess I was just looking for an excuse to make a hack. That or the fact that I&#8217;ve only had 6 hours of sleep in the past 41 hours. I see what your getting at with the other actions, and for some reason it only makes sense now that you pointed it out. I think I&#8217;ll go to sleep before I write more useless modifications for Rails.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie Hill</title>
		<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/comment-page-1/#comment-2061</link>
		<dc:creator>Jamie Hill</dc:creator>
		<pubDate>Thu, 03 Aug 2006 21:09:53 +0000</pubDate>
		<guid isPermaLink="false">16ea7a6c-c6c2-44bd-8c9c-aea8267f8ad7#comment-2061</guid>
		<description>Tristan: I really think you are over complicating things. 

Why are you so keen to get rid of the extra action in favour of a load of conditional code?

* update has edit
* create has new
* why shouldn&#039;t destroy have delete?

I would much rather have one extra action and do away with all the conditional stuff and hacks.</description>
		<content:encoded><![CDATA[<p>Tristan: I really think you are over complicating things. </p>
<p>Why are you so keen to get rid of the extra action in favour of a load of conditional code?</p>
<p>* update has edit<br />
* create has new<br />
* why shouldn&#8217;t destroy have delete?</p>
<p>I would much rather have one extra action and do away with all the conditional stuff and hacks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tristan</title>
		<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/comment-page-1/#comment-2060</link>
		<dc:creator>Tristan</dc:creator>
		<pubDate>Thu, 03 Aug 2006 20:57:54 +0000</pubDate>
		<guid isPermaLink="false">16ea7a6c-c6c2-44bd-8c9c-aea8267f8ad7#comment-2060</guid>
		<description>FYI, I&#039;m running into a problem in testing with a destroy action in another controller. Not sure if it&#039;s related, but I&#039;m going to guess and say it is.</description>
		<content:encoded><![CDATA[<p>FYI, I&#8217;m running into a problem in testing with a destroy action in another controller. Not sure if it&#8217;s related, but I&#8217;m going to guess and say it is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tristan</title>
		<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/comment-page-1/#comment-2059</link>
		<dc:creator>Tristan</dc:creator>
		<pubDate>Thu, 03 Aug 2006 20:39:52 +0000</pubDate>
		<guid isPermaLink="false">16ea7a6c-c6c2-44bd-8c9c-aea8267f8ad7#comment-2059</guid>
		<description>You got me there. Luckily, this is Rails and we can do whatever we want.

First, drop in my handy dandy hack that allows you to use arrays for method requirements: http://buckymatters.com/simply_restful_hack.rb It looks like a lot, but I assure you it&#039;s only an additional 12 lines consisting mostly of if statements.

&lt;pre&gt;
Controller:
&lt;code&gt;
def destroy
  if request.delete?
    User.find(params[:id]).destroy

    respond_to do &#124;type&#124;
      type.html { redirect_to(&#039;/&#039;) }
      type.js   { render(:update) { &#124;page&#124; page.redirect_to(&#039;/&#039;) } }
    end
  end
end
&lt;/code&gt;
&lt;/pre&gt;

&lt;pre&gt;
Routes:
&lt;code&gt;
map.resources :users
map.resources :users, :member =&gt; {:destroy =&gt; [:delete, :get]}
&lt;/code&gt;
&lt;/pre&gt;

&lt;pre&gt;
You could also use an AJAX link here, but this way requires you to always
confirm it.

View:
&lt;code&gt;
&lt;a href=&quot;&lt;%= destroy_user_url(:id =&gt; current_user.id) %&gt;&quot;&gt;
  Cancel Account
&lt;/a&gt;
&lt;/code&gt;
&lt;/pre&gt;

I obviously take arguing too seriously, but boy did I get rid of that extra action. Maybe it&#039;ll even make it to the core one day, but I doubt it.

By the way, this was my first core modification.</description>
		<content:encoded><![CDATA[<p>You got me there. Luckily, this is Rails and we can do whatever we want.</p>
<p>First, drop in my handy dandy hack that allows you to use arrays for method requirements: <a href="http://buckymatters.com/simply_restful_hack.rb" rel="nofollow">http://buckymatters.com/simply_restful_hack.rb</a> It looks like a lot, but I assure you it&#8217;s only an additional 12 lines consisting mostly of if statements.</p>
<pre>
Controller:
<code>
def destroy
  if request.delete?
    User.find(params[:id]).destroy

    respond_to do |type|
      type.html { redirect_to('/') }
      type.js   { render(:update) { |page| page.redirect_to('/') } }
    end
  end
end
</code>
</pre>
<pre>
Routes:
<code>
map.resources :users
map.resources :users, :member => {:destroy => [:delete, :get]}
</code>
</pre>
<pre>
You could also use an AJAX link here, but this way requires you to always
confirm it.

View:
<code>
<a href="<%= destroy_user_url(:id => current_user.id) %>">
  Cancel Account
</a>
</code>
</pre>
<p>I obviously take arguing too seriously, but boy did I get rid of that extra action. Maybe it&#8217;ll even make it to the core one day, but I doubt it.</p>
<p>By the way, this was my first core modification.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie</title>
		<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/comment-page-1/#comment-2062</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Thu, 03 Aug 2006 17:30:49 +0000</pubDate>
		<guid isPermaLink="false">16ea7a6c-c6c2-44bd-8c9c-aea8267f8ad7#comment-2062</guid>
		<description>Thomas: Sorry, my reply you your comment got lost.

In response to:

bq. &quot;However, if you think of the pre-action forms (new &amp; edit) as merely a way to define the parameters of the action. Then it doesn&#039;t really work for delete (or show, for that matter). Do you need parameters for the delete or show actions (other than the id)?&quot;

There may be occasions when you want to e.g. log a reason for deletion etc. That is what Iove about this method, it caters for many scenarios.</description>
		<content:encoded><![CDATA[<p>Thomas: Sorry, my reply you your comment got lost.</p>
<p>In response to:</p>
<p>bq. &#8220;However, if you think of the pre-action forms (new &#038; edit) as merely a way to define the parameters of the action. Then it doesn&#8217;t really work for delete (or show, for that matter). Do you need parameters for the delete or show actions (other than the id)?&#8221;</p>
<p>There may be occasions when you want to e.g. log a reason for deletion etc. That is what Iove about this method, it caters for many scenarios.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie</title>
		<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/comment-page-1/#comment-2049</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Sun, 30 Jul 2006 15:16:22 +0000</pubDate>
		<guid isPermaLink="false">16ea7a6c-c6c2-44bd-8c9c-aea8267f8ad7#comment-2049</guid>
		<description>Tristan: That would work if you weren&#039;t using simply restful, however with simply restful the destroy url is the same as the show url, just with a different method set.

If you fall back to /products/24 when javascript is disabled you will just get the show page as the routes have no way of telling that you wanted destroy. That is why the fallback url needs to be different i.e. /products/24;delete, you can then POST to destroy with method set to delete and the routes know what you want.

Make sense?</description>
		<content:encoded><![CDATA[<p>Tristan: That would work if you weren&#8217;t using simply restful, however with simply restful the destroy url is the same as the show url, just with a different method set.</p>
<p>If you fall back to /products/24 when javascript is disabled you will just get the show page as the routes have no way of telling that you wanted destroy. That is why the fallback url needs to be different i.e. /products/24;delete, you can then POST to destroy with method set to delete and the routes know what you want.</p>
<p>Make sense?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tristan</title>
		<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/comment-page-1/#comment-2048</link>
		<dc:creator>Tristan</dc:creator>
		<pubDate>Sun, 30 Jul 2006 06:51:13 +0000</pubDate>
		<guid isPermaLink="false">16ea7a6c-c6c2-44bd-8c9c-aea8267f8ad7#comment-2048</guid>
		<description>I think you misunderstood Rick. He&#039;s doing it the better way. Just rename delete.rhtml to destroy.rhtml and it will render that unless it&#039;s a DELETE request. So, when the form in destroy.rhtml or the JavaScript sends the DELETE request to the same URL it will delete the record and redirect to foos_url.</description>
		<content:encoded><![CDATA[<p>I think you misunderstood Rick. He&#8217;s doing it the better way. Just rename delete.rhtml to destroy.rhtml and it will render that unless it&#8217;s a DELETE request. So, when the form in destroy.rhtml or the JavaScript sends the DELETE request to the same URL it will delete the record and redirect to foos_url.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie</title>
		<link>http://thelucid.com/2006/07/26/simply-restful-the-missing-action/comment-page-1/#comment-2047</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Fri, 28 Jul 2006 13:27:27 +0000</pubDate>
		<guid isPermaLink="false">16ea7a6c-c6c2-44bd-8c9c-aea8267f8ad7#comment-2047</guid>
		<description>rcd: I am not suggesting you call destroy via a GET as you are right that would be bad.

Rabbit is right, it is simply a &quot;request&quot; to &quot;delete&quot; which gives you a form that then posts to &quot;destroy&quot;, just as &quot;new&quot; is a post to &quot;create&quot; and &quot;edit&quot; is a post to &quot;update&quot;.</description>
		<content:encoded><![CDATA[<p>rcd: I am not suggesting you call destroy via a GET as you are right that would be bad.</p>
<p>Rabbit is right, it is simply a &#8220;request&#8221; to &#8220;delete&#8221; which gives you a form that then posts to &#8220;destroy&#8221;, just as &#8220;new&#8221; is a post to &#8220;create&#8221; and &#8220;edit&#8221; is a post to &#8220;update&#8221;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
