<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Refactor your controller code by using postbacks</title>
	<link>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/</link>
	<description></description>
	<pubDate>Sat, 05 Jul 2008 00:35:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>

	<item>
		<title>By: kiloutimuk</title>
		<link>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-1716</link>
		<author>kiloutimuk</author>
		<pubDate>Wed, 12 Sep 2007 22:14:38 +0000</pubDate>
		<guid>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-1716</guid>
		<description>Hi 
 
I am really excited. Keep up the great work. Good resources here. 
 
Bye</description>
		<content:encoded><![CDATA[<p>Hi </p>
<p>I am really excited. Keep up the great work. Good resources here. </p>
<p>Bye</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matt</title>
		<link>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-41</link>
		<author>matt</author>
		<pubDate>Thu, 12 Apr 2007 14:28:31 +0000</pubDate>
		<guid>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-41</guid>
		<description>Peter - After reading your comment I have done a little searching around for ActiveRecord, but was unable to find much in the way of documentation.  After posting on ruby-forum.com DHH replied, informing me that ActiveRecord is not in rails 1.2.3 and is in fact only available through SVN!  The post is here: http://www.ruby-forum.com/topic/104657#233381</description>
		<content:encoded><![CDATA[<p>Peter - After reading your comment I have done a little searching around for ActiveRecord, but was unable to find much in the way of documentation.  After posting on ruby-forum.com DHH replied, informing me that ActiveRecord is not in rails 1.2.3 and is in fact only available through SVN!  The post is here: <a href="http://www.ruby-forum.com/topic/104657#233381" rel="nofollow">http://www.ruby-forum.com/topic/104657#233381</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Harkins</title>
		<link>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-28</link>
		<author>Peter Harkins</author>
		<pubDate>Wed, 04 Apr 2007 14:43:02 +0000</pubDate>
		<guid>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-28</guid>
		<description>ActiveResource was released in Rails 1.2 (current version is 1.2.3). I've been writing articles about routing and ActiveResource on my blog this week.</description>
		<content:encoded><![CDATA[<p>ActiveResource was released in Rails 1.2 (current version is 1.2.3). I&#8217;ve been writing articles about routing and ActiveResource on my blog this week.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matt</title>
		<link>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-27</link>
		<author>matt</author>
		<pubDate>Wed, 04 Apr 2007 08:45:25 +0000</pubDate>
		<guid>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-27</guid>
		<description>Peter - as far as I am aware ActiveResource is not actually in stable rails yet, so is not a viable solution for anyone launching a commercial application.  Please correct me if I'm wrong.  I would love to hear more about ActiveResource though.  Maybe you could post some links, or better still, write an article about it yourself, and I will publish it here.  I like your site by the way.

Cody - I do agree with you to a certain extent.  When designing a large or complex application, it is probably not good practice to create actions which handle so many requests, because as you say there is probably other logic to be done.  However, in most of my applications it is at least possible to have one get and one post request to the same action.  Obviously it is just personal preference, but I like my controllers this way.

Morgan - Thanks for the snippet.  I was considering writing the code link that, but I prefer to keep my if statements on a separate line to the logic within them.  Again, just a personal preference.  Thanks for your feedback.</description>
		<content:encoded><![CDATA[<p>Peter - as far as I am aware ActiveResource is not actually in stable rails yet, so is not a viable solution for anyone launching a commercial application.  Please correct me if I&#8217;m wrong.  I would love to hear more about ActiveResource though.  Maybe you could post some links, or better still, write an article about it yourself, and I will publish it here.  I like your site by the way.</p>
<p>Cody - I do agree with you to a certain extent.  When designing a large or complex application, it is probably not good practice to create actions which handle so many requests, because as you say there is probably other logic to be done.  However, in most of my applications it is at least possible to have one get and one post request to the same action.  Obviously it is just personal preference, but I like my controllers this way.</p>
<p>Morgan - Thanks for the snippet.  I was considering writing the code link that, but I prefer to keep my if statements on a separate line to the logic within them.  Again, just a personal preference.  Thanks for your feedback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Morgan</title>
		<link>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-26</link>
		<author>Morgan</author>
		<pubDate>Wed, 04 Apr 2007 06:57:29 +0000</pubDate>
		<guid>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-26</guid>
		<description>Some don't like the syntax, but you could shrink it like this:

&lt;code&gt;
def update
  @user = User.find_by_id(params[:id]) &#124;&#124; User.new
  if request.post?
    @user.attributes = params[:user]
    redirect_to :action =&#62; 'index' if @user.save
  end
end
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Some don&#8217;t like the syntax, but you could shrink it like this:</p>
<p><code><br />
def update<br />
  @user = User.find_by_id(params[:id]) || User.new<br />
  if request.post?<br />
    @user.attributes = params[:user]<br />
    redirect_to :action =&gt; 'index' if @user.save<br />
  end<br />
end<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cody caughlan</title>
		<link>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-24</link>
		<author>cody caughlan</author>
		<pubDate>Tue, 03 Apr 2007 22:44:36 +0000</pubDate>
		<guid>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-24</guid>
		<description>I keep seeing this same snippet all over and while its a great "getting started - look how easy it is" snippet, its not realistic. Its not representative of the actual controller code we write every day. There is no validation outside of any core ActiveRecord validation (which due to its funky limitations I completely eschew for home-grown validation) and lets face it, there is usually other logic which needs to be done.

Overall, I just dont think its very realistic that your controller code is going to be this simple.</description>
		<content:encoded><![CDATA[<p>I keep seeing this same snippet all over and while its a great &#8220;getting started - look how easy it is&#8221; snippet, its not realistic. Its not representative of the actual controller code we write every day. There is no validation outside of any core ActiveRecord validation (which due to its funky limitations I completely eschew for home-grown validation) and lets face it, there is usually other logic which needs to be done.</p>
<p>Overall, I just dont think its very realistic that your controller code is going to be this simple.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Harkins</title>
		<link>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-23</link>
		<author>Peter Harkins</author>
		<pubDate>Tue, 03 Apr 2007 16:51:29 +0000</pubDate>
		<guid>http://matt-beedle.com/2007/04/03/refactor-your-controller-code-by-using-postbacks/#comment-23</guid>
		<description>ActiveResource is the way to go on CRUD stuff. I wrote &lt;a href="http://nearbygamers.com" rel="nofollow"&gt;a site&lt;/a&gt; just as you describe and I just finished tearing all the request.post? checks out two days ago -- I'd rather have small, focused actions than long, complicated ones. A good rule for functions in any language or setting is that they should do exactly one thing. Your update action does two different things and worse, it's not even based on a flag argument but a global variable.</description>
		<content:encoded><![CDATA[<p>ActiveResource is the way to go on CRUD stuff. I wrote <a href="http://nearbygamers.com" rel="nofollow">a site</a> just as you describe and I just finished tearing all the request.post? checks out two days ago &#8212; I&#8217;d rather have small, focused actions than long, complicated ones. A good rule for functions in any language or setting is that they should do exactly one thing. Your update action does two different things and worse, it&#8217;s not even based on a flag argument but a global variable.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
