<?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"
	>
<channel>
	<title>Comments on: Better Redirects in Rails</title>
	<atom:link href="http://ethilien.net/archives/better-redirects-in-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://ethilien.net/archives/better-redirects-in-rails/</link>
	<description>I need to redo this site...</description>
	<pubDate>Wed, 23 Jul 2008 20:55:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Adam</title>
		<link>http://ethilien.net/archives/better-redirects-in-rails/#comment-10699</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Fri, 11 Apr 2008 15:11:56 +0000</pubDate>
		<guid isPermaLink="false">http://ethilien.net/archives/better-redirects-in-rails/#comment-10699</guid>
		<description>&lt;p&gt;We do something similar by marking certain points in an application as return points. &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;before_filter :mark_return_point :only =&#62;[x,z]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which does exactly the same thing and marks a return parameter in the session, we just have a &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;return_to_last_point 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;then whenever an action like an update completes redirects to the last point someone went through. &lt;/p&gt;

&lt;p&gt;Not sure which I prefer, our current way keeps the logic of the flow inside the controller&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>We do something similar by marking certain points in an application as return points. </p>

<pre><code>before_filter :mark_return_point :only =&gt;[x,z]
</code></pre>

<p>Which does exactly the same thing and marks a return parameter in the session, we just have a </p>

<pre><code>return_to_last_point 
</code></pre>

<p>then whenever an action like an update completes redirects to the last point someone went through. </p>

<p>Not sure which I prefer, our current way keeps the logic of the flow inside the controller</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Alderete</title>
		<link>http://ethilien.net/archives/better-redirects-in-rails/#comment-10686</link>
		<dc:creator>Alderete</dc:creator>
		<pubDate>Thu, 10 Apr 2008 10:30:13 +0000</pubDate>
		<guid isPermaLink="false">http://ethilien.net/archives/better-redirects-in-rails/#comment-10686</guid>
		<description>&lt;p&gt;On further testing, neither the original nor my altered version of the helper handle the case of a generated show link, which simply passes in an ActiveRecord object:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&#60;%= link_away h(person.display_name), person %&#62;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(person also gets passed for generated delete links.)&lt;/p&gt;

&lt;p&gt;Not really sure what the answer is, except to only use link_away for edit links.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>On further testing, neither the original nor my altered version of the helper handle the case of a generated show link, which simply passes in an ActiveRecord object:</p>

<pre><code>&lt;%= link_away h(person.display_name), person %&gt;
</code></pre>

<p>(person also gets passed for generated delete links.)</p>

<p>Not really sure what the answer is, except to only use link_away for edit links.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Alderete</title>
		<link>http://ethilien.net/archives/better-redirects-in-rails/#comment-10684</link>
		<dc:creator>Alderete</dc:creator>
		<pubDate>Thu, 10 Apr 2008 10:11:15 +0000</pubDate>
		<guid isPermaLink="false">http://ethilien.net/archives/better-redirects-in-rails/#comment-10684</guid>
		<description>&lt;p&gt;I notice that this isn't quite a drop-in replacement for the link_to code that is generated by the Rails 2.0 scaffolding generator, specifically, the URL helpers generated by using map.resources in routes.rb, e.g.:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&#60;%= link_away 'Edit', edit_person_path(@person) %&#62;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Will fail with the error "undefined method `symbolize_keys' for "/people/1/edit":String"&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def link_away(name, options = {}, html_options = nil)
    link = case options
        when String
            link_to(name, options + "?return_uri=" + url_for(:only_path =&#62; true), html_options)
        else
            link_to(name, { :return_uri =&#62; url_for(:only_path =&#62; true) }.update(options.symbolize_keys), html_options)
        end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But that's fairly unsatisfying, if for no reason than it will add an extra "?" to the URL if there are already parameters in it. (My Ruby-fu is weak.)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I notice that this isn&#8217;t quite a drop-in replacement for the link_to code that is generated by the Rails 2.0 scaffolding generator, specifically, the URL helpers generated by using map.resources in routes.rb, e.g.:</p>

<pre><code>&lt;%= link_away 'Edit', edit_person_path(@person) %&gt;
</code></pre>

<p>Will fail with the error &#8220;undefined method `symbolize_keys&#8217; for &#8220;/people/1/edit&#8221;:String&#8221;</p>

<pre><code>def link_away(name, options = {}, html_options = nil)
    link = case options
        when String
            link_to(name, options + "?return_uri=" + url_for(:only_path =&gt; true), html_options)
        else
            link_to(name, { :return_uri =&gt; url_for(:only_path =&gt; true) }.update(options.symbolize_keys), html_options)
        end
end
</code></pre>

<p>But that&#8217;s fairly unsatisfying, if for no reason than it will add an extra &#8220;?&#8221; to the URL if there are already parameters in it. (My Ruby-fu is weak.)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony</title>
		<link>http://ethilien.net/archives/better-redirects-in-rails/#comment-10439</link>
		<dc:creator>Anthony</dc:creator>
		<pubDate>Wed, 26 Mar 2008 23:34:42 +0000</pubDate>
		<guid isPermaLink="false">http://ethilien.net/archives/better-redirects-in-rails/#comment-10439</guid>
		<description>&lt;p&gt;Very nice. Simple, basic, almost obvious. But really helps to tighten up recurring crap in controller code.&lt;/p&gt;

&lt;p&gt;Thanks for sharing!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Very nice. Simple, basic, almost obvious. But really helps to tighten up recurring crap in controller code.</p>

<p>Thanks for sharing!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://ethilien.net/archives/better-redirects-in-rails/#comment-10437</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Wed, 26 Mar 2008 22:22:27 +0000</pubDate>
		<guid isPermaLink="false">http://ethilien.net/archives/better-redirects-in-rails/#comment-10437</guid>
		<description>&lt;p&gt;Very handy ideas!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Very handy ideas!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: DHH</title>
		<link>http://ethilien.net/archives/better-redirects-in-rails/#comment-10379</link>
		<dc:creator>DHH</dc:creator>
		<pubDate>Sun, 23 Mar 2008 16:17:15 +0000</pubDate>
		<guid isPermaLink="false">http://ethilien.net/archives/better-redirects-in-rails/#comment-10379</guid>
		<description>&lt;p&gt;Those are some neat patterns. You should wrap them up in a plugin.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Those are some neat patterns. You should wrap them up in a plugin.</p>]]></content:encoded>
	</item>
</channel>
</rss>
