method
build
rails latest stable - Class:
ActionController::Routing::RouteBuilder
Method deprecated or moved
This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.
build(path, options)public
Construct and return a route with the given path and options.
# File actionpack/lib/action_controller/routing/builder.rb, line 157
def build(path, options)
# Wrap the path with slashes
path = "/#{path}" unless path[0] == ?/
path = "#{path}/" unless path[-1] == ?/
prefix = options[:path_prefix].to_s.gsub(/^\//,'')
path = "/#{prefix}#{path}" unless prefix.blank?
segments = segments_for_route_path(path)
defaults, requirements, conditions = divide_route_options(segments, options)
requirements = assign_route_options(segments, defaults, requirements)
# TODO: Segments should be frozen on initialize
segments.each { |segment| segment.freeze }
route = Route.new(segments, requirements, conditions)
if !route.significant_keys.include?(:controller)
raise ArgumentError, "Illegal route: the :controller must be specified!"
end
route.freeze
end Related methods
- Instance methods
- assign_default_route_options
- assign_route_options
- build
- divide_route_options
- ensure_required_segments
- segment_for
- segments_for_route_path
- Class methods
- new
- Private methods
-
validate_route_conditions