<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Isshen, LLC: Gotcha: Defining a controller action called 'process'</title>
    <link>http://blog.isshen.com/articles/2007/08/23/gotcha-defining-a-controller-action-called-process</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Gotcha: Defining a controller action called 'process'</title>
      <description>&lt;p&gt;Early in the morning on #rubyonrails, someone came into channel asking for help. He said that, inexplicably, on controller out of his several controllers stopped functioning. When asked for a log, he gave &lt;a href="http://pastie.caboo.se/90295"&gt;this pastie&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is very puzzling. I even looked at the code around line 330 in ActionController:base&lt;/p&gt;

&lt;blockquote&gt;
327     class &lt;&lt; self&lt;br/&gt;
328       # Factory for the standard create, process loop where the controller is discarded after processing.&lt;br/&gt;
329       def process(request, response) #:nodoc:&lt;br/&gt;
330         new.process(request, response)&lt;br/&gt;
331       end&lt;br/&gt;
&lt;/blockquote&gt;

&lt;p&gt;When asked about what his controller looked like, he gave &lt;a href="http://pastie.caboo.se/90300"&gt;this pastie.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Can you spot the error?&lt;/p&gt;



&lt;h3&gt;The Gotcha&lt;/h3&gt;

&lt;p&gt;As commented in ActionController::base, a new instance of the controller is generated and the method process is called. Unfortunately, all actions are also method definitions. By attempting to define an action called 'process', it overwrote the original process. That explained the error with the "Wrong number of arguments."&lt;/p&gt;

&lt;h3&gt;The Judgment&lt;/h3&gt;

&lt;p&gt;Don't name your action 'process'. And more importantly, dig into the code when you get weird errors like this.&lt;/p&gt;

-Hosh</description>
      <pubDate>Thu, 23 Aug 2007 04:48:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:d96cad7f-ab25-46af-a370-93a4d99b6030</guid>
      <author>Hosh</author>
      <link>http://blog.isshen.com/articles/2007/08/23/gotcha-defining-a-controller-action-called-process</link>
      <category>Ruby on Rails</category>
      <category>ruby_on_rails</category>
      <category>gotcha</category>
    </item>
  </channel>
</rss>
