Browse files

Reorder the way in which map.resource routes are added to the set. Th…

…is prevents the singular named route from hitting :create instead of :show.

Signed-off-by: Michael Koziarski <>
  • Loading branch information...
1 parent 41abbe4 commit 43a06d07a899be9505bb3c11422a3fd5ba7d0c38 @geoffgarside geoffgarside committed with NZKoz Nov 18, 2008
Showing with 1 addition and 1 deletion.
  1. +1 −1 actionpack/lib/action_controller/resources.rb
2 actionpack/lib/action_controller/resources.rb
@@ -535,9 +535,9 @@ def map_singleton_resource(entities, options = {}, &block)
with_options :controller => resource.controller do |map|
map_collection_actions(map, resource)
- map_default_singleton_actions(map, resource)
map_new_actions(map, resource)
map_member_actions(map, resource)
+ map_default_singleton_actions(map, resource)
map_associations(resource, options)

3 comments on commit 43a06d0


Could this in any way be causing the following behavior?

I have a namespaced resource:

map.namespace :mainframe do |mainframe|
mainframe.resource :configuration, :controller => "configuration"

When I navigate to /mainframe/configuration, ConfigurationController#show is rendered (so far so good).

In my form (which, yes, I have under the #show action – long story), I have:

&lt;% form_for :configuration, :html =&gt; {:method =&gt; :put, :url =&gt; mainframe_configuration_path} do |f| %&gt; ... &lt;% end %&gt;

which has the following HTML:

&lt;form action=&quot;/mainframe/configuration&quot; method=&quot;post&quot; url=&quot;/mainframe/configuration&quot;&gt;&lt;div style=&quot;margin:0;padding:0&quot;&gt;&lt;input name=&quot;_method&quot; type=&quot;hidden&quot; value=&quot;put&quot; /&gt;&lt;/div&gt;

Again, so far so good. This hits Configuration#update, as is intended:

def update
  if @configuration.update_attributes(params[:configuration])
    flash[:notice] = 'Your system configuration was successfully updated.'
    redirect_to mainframe_configuration_url
    render :action=&gt;&quot;show&quot;

See that last bit? The “mainframe_configuration_path”? For whatever reason, that is redirecting to /mainframe/configuration/edit. The object is being updated, and there are only two actions in this controller – so I know it’s hitting the right action, etc. But calling mainframe_configuration_url (which, according to rake routes should be #show) is sending it to #edit.


GRAH. You’re kidding me. I spent all that time formatting my code, as described in the “Textile Enabled” link, and it flipping does this?


Grr. Scratch it all. I found it.

Please sign in to comment.