<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: action code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 07:25:07 GMT</pubDate>
    <description>DZone Snippets: action code</description>
    <item>
      <title>Firing a controller's action from the console</title>
      <link>http://snippets.dzone.com/posts/show/600</link>
      <description>It seems like a simple task, but here's how you can simulate the calling of a controller's action:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ruby script/console&lt;br /&gt;&lt;br /&gt;irb&gt; require 'action_controller/test_process'&lt;br /&gt;irb&gt; require 'application'&lt;br /&gt;irb&gt; require 'site_controller'&lt;br /&gt;irb&gt; request = ActionController::TestRequest.new&lt;br /&gt;irb&gt; response = ActionController::TestResponse.new&lt;br /&gt;irb&gt; request.env['REQUEST_METHOD'] = 'GET'&lt;br /&gt;irb&gt; request.action = "late_employee"&lt;br /&gt;irb&gt; InfoController.process(request,response)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Basically, it's like getting inside of a TestUnit method, but you have to do the dirty work yourself.</description>
      <pubDate>Fri, 26 Aug 2005 02:44:03 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/600</guid>
      <author>canadaduane (Duane Johnson)</author>
    </item>
  </channel>
</rss>
