programmable-ventouse 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/ventouse.rb CHANGED
@@ -3,5 +3,6 @@ require 'ventouse/filter_prefix'
3
3
  require 'ventouse/module_declarations'
4
4
  require 'ventouse/rename_type_column'
5
5
  require 'ventouse/rescue_ext'
6
+ require 'ventouse/resource_as_root'
6
7
 
7
8
  require 'ventouse/mysql_initializer'
@@ -0,0 +1,27 @@
1
+ # Fix routing to enable this:
2
+ #
3
+ # map.resources :organizations, :as => :root
4
+ #
5
+ # to produce this:
6
+ #
7
+ # organizations GET /
8
+ # new_organization GET /new
9
+ # edit_organization GET /:id/edit
10
+ # organization GET /:id
11
+ #
12
+ module ResourceAsRoot
13
+ module ResourcesHacks
14
+ def map_resource_routes map, resource, action, route_path, *args
15
+ route_path.gsub!(/\/\//, '/')
16
+ super
17
+ end
18
+
19
+ def map_resource entities, options = {}, *args
20
+ options[:as] = '' if options[:as] == :root
21
+ super
22
+ end
23
+ end
24
+ end
25
+
26
+ ActionController::Resources.send :include, ResourceAsRoot::ResourcesHacks
27
+ ActionController::Routing::RouteSet::Mapper.send :include, ResourceAsRoot::ResourcesHacks # Just cause it's too late
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: programmable-ventouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilia Ablamonov
@@ -42,6 +42,7 @@ files:
42
42
  - lib/ventouse/mysql_initializer.rb
43
43
  - lib/ventouse/rename_type_column.rb
44
44
  - lib/ventouse/rescue_ext.rb
45
+ - lib/ventouse/resource_as_root.rb
45
46
  - lib/ventouse.rb
46
47
  has_rdoc: true
47
48
  homepage: http://github.com/programmable/ventouse