<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: controller code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 08:51:21 GMT</pubDate>
    <description>DZone Snippets: controller 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>
    <item>
      <title>Render a partial to an instance variable</title>
      <link>http://snippets.dzone.com/posts/show/396</link>
      <description>Normally, if you call "render_partial" within a controller, nothing but the partial will be rendered.&lt;br /&gt;&lt;br /&gt;Occasionally, it is useful to render a partial to an instance variable as a string so that the view can still be rendered as normal, and the string can be passed in to the view.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  add_variables_to_assigns&lt;br /&gt;  @content_for_navbar = @template.render_partial 'layouts/public_navbar'&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 19 Jun 2005 15:27:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/396</guid>
      <author>canadaduane (Duane Johnson)</author>
    </item>
  </channel>
</rss>
