--- resources_controller.rb +++ (clipboard) @@ -735,7 +735,7 @@ end rescue MissingSegment # fallback: construct enclosing names from param ids - @route_enclosing_names = params.keys.select{|k| k.to_s =~ /_id$/}.map{|id| [id.sub('_id','').pluralize, false]} + @route_enclosing_names = params.keys.select{|k| k.to_s =~ /_id$/}.map{|id| [id.sub('_id','').pluralize, false]}.reverse end # this is the before_filter that loads all specified and wildcard resources --- specification.rb +++ (clipboard) @@ -71,7 +71,7 @@ # finds the resource on a controller using enclosing resources or resource class def find_resource(controller) - (controller.enclosing_resource ? controller.enclosing_resource.send(source) : klass).find controller.params[key] + (controller.enclosing_resource && controller.enclosing_resource.respond_to?(source) ? controller.enclosing_resource.send(source) : klass).find controller.params[key] end end