instance method
defaults
Ruby on Rails 7.0.10
Since v3.0.20Signature
defaults(defaults = {})
Allows you to set default parameters for a route, such as this:
defaults id: 'home' do match 'scoped_pages/(:id)', to: 'pages#show' end
Using this, the :id parameter here will default to ‘home’.
Parameters
-
defaultsopt = {}
Source
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 1008
def defaults(defaults = {})
@scope = @scope.new(defaults: merge_defaults_scope(@scope[:defaults], defaults))
yield
ensure
@scope = @scope.parent
end
Defined in actionpack/lib/action_dispatch/routing/mapper.rb line 1008
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Routing::Mapper::Scoping