<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -16,10 +16,42 @@ class ControllerGenerator &lt; Genosaurus
   end
   
   def after_generate # :nodoc:
+    add_actions
+    update_routes_file
+    ControllerHelperGenerator.run(@options)
+  end
+  
+  private
+  def update_routes_file # :nodoc:
+    unless @actions.empty?
+      routes = File.join(Mack.root, &quot;config&quot;, &quot;routes.rb&quot;)
+      rf = File.open(routes).read
+      unless rf.match(&quot;.resource :#{@name_plural}&quot;)
+        puts &quot;Updating routes.rb&quot;
+        nrf = &quot;&quot;
+        rf.each do |line|
+          if line.match(&quot;Mack::Routes.build&quot;)
+            x = line.match(/\|(.+)\|/).captures
+            line &lt;&lt; &quot;\n  # Added by rake generate:controller name=#{param(:name)} actions=#{param(:actions)}\n&quot;
+            line &lt;&lt; &quot;\n  r.with_options(:controller =&gt; :#{@name_plural}) do |map|\n&quot;
+            @actions.each do |action|
+              line &lt;&lt; &quot;\n    map.#{@name_plural}_#{action}_url \&quot;/#{@name_plural}#{action == &quot;index&quot; ? &quot;&quot; : &quot;/#{action}&quot;}\&quot;, :action =&gt; :#{action}&quot;
+            end
+            line &lt;&lt; &quot;\n  end # #{@name_plural}\n&quot;
+          end
+          nrf &lt;&lt; line
+        end
+        File.open(routes, &quot;w&quot;) do |f|
+          f.puts nrf
+        end
+      end
+    end
+  end
+  
+  def add_actions
     @actions.each do |action|
       template(action_template(action), File.join(&quot;app&quot;, &quot;views&quot;, @name_plural, &quot;#{action}.html.erb&quot;))
-    end
-    ControllerHelperGenerator.run(@options)
+    end    
   end
   
   def action_template(action) # :nodoc:</diff>
      <filename>lib/mack/generators/controller_generator/controller_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,10 +12,15 @@ describe ControllerGenerator do
   
   before(:each) do
     common_cleanup
+    @route_file_loc = File.join(Mack.root, &quot;config&quot;, &quot;routes.rb&quot;)
+    @original_route_file = File.read(@route_file_loc)
   end
   
   after(:each) do
     common_cleanup
+    File.open(@route_file_loc, &quot;w&quot;) do |f|
+      f.puts @original_route_file
+    end
   end
   
   it &quot;should require a name parameter&quot; do
@@ -36,6 +41,15 @@ describe ControllerGenerator do
     File.read(show).should match(/&lt;p&gt;You can find me in app\/views\/zoos\/show.html.erb&lt;\/p&gt;/)
   end
   
+  it &quot;should update the routes file if there are actions&quot; do
+    ControllerGenerator.run(&quot;name&quot; =&gt; &quot;zoo&quot;, &quot;actions&quot; =&gt; &quot;index,show&quot;)
+    File.read(@route_file_loc).should match(/  # Added by rake generate:controller name=zoo actions=index,show/)
+    File.read(@route_file_loc).should match(/  r.with_options\(:controller =&gt; :zoos\) do \|map\|/)
+    File.read(@route_file_loc).should match(/    map.zoos_index_url &quot;\/zoos&quot;, :action =&gt; :index/)
+    File.read(@route_file_loc).should match(/    map.zoos_show_url &quot;\/zoos\/show&quot;, :action =&gt; :show/)
+    File.read(@route_file_loc).should match(/  end # zoos/)
+  end
+  
   it &quot;should generate a controller&quot; do
     file = File.join(Mack.root, &quot;app&quot;, &quot;controllers&quot;, &quot;zoos_controller.rb&quot;)
     File.should_not be_exists(file)</diff>
      <filename>test/unit/generators/controller_generator_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>32524881c1f10c595d6d918a618284eba6a63969</id>
    </parent>
  </parents>
  <author>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </author>
  <url>http://github.com/markbates/mack/commit/9502e60855e78a9c9319e45ce7a75162a92d7cb1</url>
  <id>9502e60855e78a9c9319e45ce7a75162a92d7cb1</id>
  <committed-date>2008-08-05T09:01:23-07:00</committed-date>
  <authored-date>2008-08-05T09:01:23-07:00</authored-date>
  <message>ControllerGenerator now adds actions to the routes file. [#25 state:resolved]</message>
  <tree>16aaf8c46a35ba6f3ac3b1cf6f869a219964c10f</tree>
  <committer>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </committer>
</commit>
