module ActionDispatch::Routing::Mapper::Scoping

def scope(*args)

end
resources :posts
scope as: "sekret" do
# prefix the routing helper name: +sekret_posts_path+ instead of +posts_path+

end
resources :posts
scope path: "/admin" do
# prefix the posts resource's requests with '/admin'

end
resources :posts
scope module: "admin" do
# route /posts (without the prefix /admin) to +Admin::PostsController+

Takes same options as Base#match and Resources#resources.

=== Options

rather than /accounts/:account_id/projects.
The difference here being that the routes generated are like /:account_id/projects,
This generates helpers such as +account_projects_path+, just like +resources+ does.

end
resources :projects
scope path: ":account_id", as: "account" do

Take the following route definition as an example:

Scopes a set of routes to the given default options.
def scope(*args)
  options = args.extract_options!.dup
  scope = {}
  options[:path] = args.flatten.join("/") if args.any?
  options[:constraints] ||= {}
  unless nested_scope?
    options[:shallow_path] ||= options[:path] if options.key?(:path)
    options[:shallow_prefix] ||= options[:as] if options.key?(:as)
  end
  if options[:constraints].is_a?(Hash)
    defaults = options[:constraints].select do |k, v|
      URL_OPTIONS.include?(k) && (v.is_a?(String) || v.is_a?(Integer))
    end
    options[:defaults] = defaults.merge(options[:defaults] || {})
  else
    block, options[:constraints] = options[:constraints], {}
  end
  if options.key?(:only) || options.key?(:except)
    scope[:action_options] = { only: options.delete(:only),
                               except: options.delete(:except) }
  end
  if options.key? :anchor
    raise ArgumentError, "anchor is ignored unless passed to `match`"
  end
  @scope.options.each do |option|
    if option == :blocks
      value = block
    elsif option == :options
      value = options
    else
      value = options.delete(option) { POISON }
    end
    unless POISON == value
      scope[option] = send("merge_#{option}_scope", @scope[option], value)
    end
  end
  @scope = @scope.new scope
  yield
  self
ensure
  @scope = @scope.parent
end