def create_resources_url_helpers!
        resource_segments, resource_ivars = [], []
        resource_config = self.resources_configuration[:self]

        singleton   = resource_config[:singleton]
        uncountable = !singleton && resource_config[:route_collection_name] == resource_config[:route_instance_name]
        polymorphic = self.parents_symbols.include?(:polymorphic)

        # Add route_prefix if any.
        unless resource_config[:route_prefix].blank?
          if polymorphic
            resource_ivars << resource_config[:route_prefix].to_s
          else
            resource_segments << resource_config[:route_prefix]
          end
        end

        # Deal with belongs_to associations and polymorphic associations.
        # Remember that we don't have to build the segments in polymorphic cases,
        # because the url will be polymorphic_url.
        #
        self.parents_symbols.each do |symbol|
          if symbol == :polymorphic
            resource_ivars << :parent
          else
            config = self.resources_configuration[symbol]
            if config[:singleton] && polymorphic
              resource_ivars << config[:instance_name]
            else
              resource_segments << config[:route_name]
            end
            if !config[:singleton]
              resource_ivars    << :"@#{config[:instance_name]}"
            end
          end
        end

        collection_ivars    = resource_ivars.dup
        collection_segments = resource_segments.dup

        # Generate parent url before we add resource instances.
        unless parents_symbols.empty?
          generate_url_and_path_helpers nil,   :parent, resource_segments, resource_ivars
          generate_url_and_path_helpers :edit, :parent, resource_segments, resource_ivars
        end

        # In singleton cases, we do not send the current element instance variable
        # because the id is not in the URL. For example, we should call:
        #
        #   project_manager_url(@project)
        #
        # Instead of:
        #
        #   project_manager_url(@project, @manager)
        #
        # Another exception in singleton cases is that collection url does not
        # exist. In such cases, we create the parent collection url. So in the
        # manager case above, the collection url will be:
        #
        #    project_url(@project)
        #
        # If the singleton does not have a parent, it will default to root_url.
        #
        collection_segments << resource_config[:route_collection_name] unless singleton
        resource_segments   << resource_config[:route_instance_name]
        resource_ivars      << :"@#{resource_config[:instance_name]}" unless singleton

        # Finally, polymorphic cases we have to give hints to the polymorphic url
        # builder. This works by attaching new ivars as symbols or records.
        #
        if polymorphic && singleton
          resource_ivars << resource_config[:instance_name]
          new_ivars       = resource_ivars
        end

        # If route is uncountable then add "_index" suffix to collection index route name
        if uncountable
          collection_segments << :"#{collection_segments.pop}_index"
        end

        generate_url_and_path_helpers nil,   :collection, collection_segments, collection_ivars
        generate_url_and_path_helpers :new,  :resource,   resource_segments,   new_ivars || collection_ivars
        generate_url_and_path_helpers nil,   :resource,   resource_segments,   resource_ivars
        generate_url_and_path_helpers :edit, :resource,   resource_segments,   resource_ivars

        if resource_config[:custom_actions]
          [*resource_config[:custom_actions][:resource]].each do | method |
            generate_url_and_path_helpers method, :resource, resource_segments, resource_ivars
          end
          [*resource_config[:custom_actions][:collection]].each do | method |
            generate_url_and_path_helpers method, :resources, collection_segments, collection_ivars
          end
        end
      end
def create_resources_url_helpers!
        resource_segments, resource_ivars = [], []
        resource_config = self.resources_configuration[:self]

        singleton   = resource_config[:singleton]
        uncountable = !singleton && resource_config[:route_collection_name] == resource_config[:route_instance_name]
        polymorphic = self.parents_symbols.include?(:polymorphic)

        # Add route_prefix if any.
        unless resource_config[:route_prefix].blank?
          if polymorphic
            resource_ivars << resource_config[:route_prefix].to_s
          else
            resource_segments << resource_config[:route_prefix]
          end
        end

        # Deal with belongs_to associations and polymorphic associations.
        # Remember that we don't have to build the segments in polymorphic cases,
        # because the url will be polymorphic_url.
        #
        self.parents_symbols.each do |symbol|
          if symbol == :polymorphic
            resource_ivars << :parent
          else
            config = self.resources_configuration[symbol]
            if config[:singleton] && polymorphic
              resource_ivars << config[:instance_name]
            else
              resource_segments << config[:route_name]
            end
            if !config[:singleton]
              resource_ivars    << :"@#{config[:instance_name]}"
            end
          end
        end

        collection_ivars    = resource_ivars.dup
        collection_segments = resource_segments.dup

        # Generate parent url before we add resource instances.
        unless parents_symbols.empty?
          generate_url_and_path_helpers nil,   :parent, resource_segments, resource_ivars
          generate_url_and_path_helpers :edit, :parent, resource_segments, resource_ivars
        end

        # In singleton cases, we do not send the current element instance variable
        # because the id is not in the URL. For example, we should call:
        #
        #   project_manager_url(@project)
        #
        # Instead of:
        #
        #   project_manager_url(@project, @manager)
        #
        # Another exception in singleton cases is that collection url does not
        # exist. In such cases, we create the parent collection url. So in the
        # manager case above, the collection url will be:
        #
        #    project_url(@project)
        #
        # If the singleton does not have a parent, it will default to root_url.
        #
        collection_segments << resource_config[:route_collection_name] unless singleton
        resource_segments   << resource_config[:route_instance_name]
        resource_ivars      << :"@#{resource_config[:instance_name]}" unless singleton

        # Finally, polymorphic cases we have to give hints to the polymorphic url
        # builder. This works by attaching new ivars as symbols or records.
        #
        if polymorphic && singleton
          resource_ivars << resource_config[:instance_name]
          new_ivars       = resource_ivars
        end

        # If route is uncountable then add "_index" suffix to collection index route name
        if uncountable
          collection_segments << :"#{collection_segments.pop}_index"
        end

        generate_url_and_path_helpers nil,   :collection, collection_segments, collection_ivars
        generate_url_and_path_helpers :new,  :resource,   resource_segments,   new_ivars || collection_ivars
        generate_url_and_path_helpers nil,   :resource,   resource_segments,   resource_ivars
        generate_url_and_path_helpers :edit, :resource,   resource_segments,   resource_ivars

        if resource_config[:custom_actions]
          [*resource_config[:custom_actions][:resource]].each do | method |
            generate_url_and_path_helpers method, :resource, resource_segments, resource_ivars
          end
          [*resource_config[:custom_actions][:collection]].each do | method |
            generate_url_and_path_helpers method, :resources, collection_segments, collection_ivars
          end
        end
      end
This method hard code url helpers in the class.

 We are doing this because is cheaper than guessing them when our action
 is being processed (and even more cheaper when we are using nested
 resources).

 When we are using polymorphic associations, those helpers rely on
 polymorphic_url Rails helper.