Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
ActionController::Resources::Resource.class_eval do
  def path
    @path ||= (path_prefix != false ? "#{path_prefix}/#{path_segment}" : '')
  end
end

ActionController::Resources.module_eval do
  def map_default_collection_actions(map, resource)
    index_action_options = action_options_for("index", resource)
    index_route_name = "#{resource.name_prefix}#{resource.plural}"

    if resource.uncountable?
      index_route_name << "_index"
    end
    formatted_index_path = (resource.path_prefix ? "#{resource.path}.:format" : "#{index_route_name}.:format")

    map.named_route(index_route_name, resource.path, index_action_options)
    map.named_route("formatted_#{index_route_name}", formatted_index_path, index_action_options)

    create_action_options = action_options_for("create", resource)
    map.connect(resource.path, create_action_options)
    map.connect(formatted_index_path, create_action_options)
  end
end