<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -33,22 +33,63 @@ module Restflection
       name.singularize.classify.constantize
     end
 
-    URL_HELPER_FORMAT = /(?:hash_for_formatted|hash_for|formatted)_/
-    URL_HELPER_ACTION = /.*?_/
+    URL_HELPER_FORMAT = /(?:hash_for_formatted|hash_for|formatted)/
+    URL_HELPER_ACTION = /.*?/
     URL_HELPER_SUFFIX = /url|path/
     
-    URL_HELPER = /\A(#{URL_HELPER_FORMAT})?(#{URL_HELPER_ACTION})?(#{URL_HELPER_SUFFIX})\Z/
+    URL_HELPER = /\A(?:(#{URL_HELPER_FORMAT})_)?(?:(#{URL_HELPER_ACTION})_)?(#{URL_HELPER_SUFFIX})\Z/
     
     def method_missing(method_name, *args)
       if method_name.to_s =~ URL_HELPER
-        parts = []
-        3.times { |i| parts &lt;&lt; method_name.to_s.sub(URL_HELPER, &quot;\\#{i + 1}&quot;) }
-        url_helper = parts[0] + name_prefix + parts[1] + name + &quot;_&quot; + parts[2]
+        format, action, suffix = parse_url_helper(method_name)
+        
+        url_helper = build_helper_method(format, action, suffix)
+        args &lt;&lt; it if args.empty? &amp;&amp; member? &amp;&amp; member_action?(action)
+        
         @controller.send(url_helper, *args)
       else
         raise NoMethodError.new(&quot;undefined method '#{method_name}'&quot;, method_name, args)
       end
     end
+
+    private
+
+      def member?
+        name == name.singularize
+      end
+
+      def member_action?(name)
+        if name.blank? # action is &quot;show&quot;
+          member_action = true
+        else
+          member_action = false
+          resource = ::ActionController::Resources.resources[@controller.controller_name]
+          if resource
+            Array(resource.member_methods).each do |method|
+              member_action = true if method.include?(name.to_sym)
+            end
+          end
+        end
+      end
+
+      def parse_url_helper(name)
+        returning parts = [] do
+          3.times do |i|
+            part = name.to_s.sub(URL_HELPER, &quot;\\#{i + 1}&quot;)
+            part = nil if part.blank?
+            parts &lt;&lt; part
+          end
+        end
+      end
+
+      def build_helper_method(format, action, suffix)
+        returning url_helper = &quot;&quot; do
+          url_helper &lt;&lt; format + &quot;_&quot; if format
+          url_helper &lt;&lt; name_prefix
+          url_helper &lt;&lt; action + &quot;_&quot; if action
+          url_helper &lt;&lt; name + &quot;_&quot; + suffix
+        end
+      end
     
   end
 end</diff>
      <filename>lib/restflection/resource_reflection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,8 @@ module Restflection
     include SharedStubs
 
     before do
-      @reflection = ResourceReflection.new(controller_stub, &quot;account&quot;)
+      @reflection = ResourceReflection.new(controller_stub(:controller_name =&gt; &quot;accounts&quot;), &quot;account&quot;)
+      ::ActionController::Resources.stubs(:resources).returns(&quot;accounts&quot; =&gt; stub(:member_methods =&gt; { :get =&gt; [ :edit ] }))
     end
 
     it &quot;should have an empty name prefix&quot; do
@@ -51,7 +52,25 @@ module Restflection
       @reflection.formatted_new_path
     end
 
-    it &quot;should automatically pass the resource to member methods&quot;
+    it &quot;should automatically pass the resource to specific member actions if not passed any arguments&quot; do
+      account = stub
+      @reflection.expects(:it).returns(account)
+      @controller.expects(:edit_account_path).with(account)
+      @reflection.edit_path
+    end
+
+    it &quot;should automatically pass the resource to the 'show' action if not passed any arguments&quot; do
+      account = stub
+      @reflection.expects(:it).returns(account)
+      @controller.expects(:account_path).with(account)
+      @reflection.path
+    end
+
+    it &quot;should pass the arguments straight to member methods if given&quot; do
+      arguments = [stub, stub]
+      @controller.expects(:edit_account_path).with(*arguments)
+      @reflection.edit_path(*arguments)
+    end
 
     it &quot;should raise a NoMethodError if the method does not match&quot; do
       lambda { @reflection.every_man_is_an_island }.should raise_error(NoMethodError, &quot;undefined method 'every_man_is_an_island'&quot;)
@@ -68,7 +87,8 @@ module Restflection
     include SharedStubs
 
     before do
-      @reflection = ResourceReflection.new(controller_stub, &quot;comment&quot;)
+      @reflection = ResourceReflection.new(controller_stub(:controller_name =&gt; &quot;comments&quot;), &quot;comment&quot;)
+      ::ActionController::Resources.stubs(:resources).returns(&quot;comments&quot; =&gt; stub(:member_methods =&gt; { :get =&gt; [ :edit ] }))
       @reflection.name_prefix = &quot;article_&quot;
     end
 </diff>
      <filename>spec/restflection/resource_reflection_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d35e15d2713f74a3aac60a264f89f471232ef0eb</id>
    </parent>
  </parents>
  <author>
    <name>Jon Leighton</name>
    <email>j@jonathanleighton.com</email>
  </author>
  <url>http://github.com/jonleighton/restflection/commit/f4d26be58dd085c2bebef64922c768ed4184fbda</url>
  <id>f4d26be58dd085c2bebef64922c768ed4184fbda</id>
  <committed-date>2007-05-31T16:52:24-07:00</committed-date>
  <authored-date>2007-05-31T16:52:24-07:00</authored-date>
  <message>Auto pass members to member url helpers</message>
  <tree>b17f2df71b954dbd6452d0c60f71d4a6583e3313</tree>
  <committer>
    <name>Jon Leighton</name>
    <email>j@jonathanleighton.com</email>
  </committer>
</commit>
