Sha256: 7a29c376d0b56e5700cb3853201a81a44657b398d45b2546a54586fdd3197305

Contents?: true

Size: 734 Bytes

Versions: 13

Compression:

Stored size: 734 Bytes

Contents

# Fix routing to enable this:
#
# map.resources :organizations, :as => :root
#
# to produce this:
#
#          organizations GET /
#       new_organization GET /new
#      edit_organization GET /:id/edit
#           organization GET /:id
#
module ResourceAsRoot
  module ResourcesHacks
    def map_resource_routes map, resource, action, route_path, *args
      route_path.gsub!(/\/\//, '/')
      super
    end

    def map_resource entities, options = {}, *args
      options[:as] = '' if options[:as] == :root
      super
    end
  end
end

ActionController::Resources.send :include, ResourceAsRoot::ResourcesHacks
ActionController::Routing::RouteSet::Mapper.send :include, ResourceAsRoot::ResourcesHacks # Just cause it's too late

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
programmable-ventouse-0.0.10 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.0.4 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.0.5 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.0.7 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.0.8 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.0.9 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.1.0 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.1.1 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.1.2 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.1.3 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.1.4 lib/ventouse/resource_as_root.rb
programmable-ventouse-0.1.5 lib/ventouse/resource_as_root.rb
ventouse-0.1.6 lib/ventouse/resource_as_root.rb