mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #29344 from y-yagi/fix_doc_format
Fix formatting of `direct` and `resolve` doc [ci skip]
This commit is contained in:
commit
d45a0e7163
1 changed files with 14 additions and 14 deletions
|
@ -2038,8 +2038,8 @@ module ActionDispatch
|
||||||
# { controller: "pages", action: "index", subdomain: "www" }
|
# { controller: "pages", action: "index", subdomain: "www" }
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# The return value from the block passed to `direct` must be a valid set of
|
# The return value from the block passed to +direct+ must be a valid set of
|
||||||
# arguments for `url_for` which will actually build the URL string. This can
|
# arguments for +url_for+ which will actually build the URL string. This can
|
||||||
# be one of the following:
|
# be one of the following:
|
||||||
#
|
#
|
||||||
# * A string, which is treated as a generated URL
|
# * A string, which is treated as a generated URL
|
||||||
|
@ -2058,17 +2058,17 @@ module ActionDispatch
|
||||||
# [ :products, options.merge(params.permit(:page, :size).to_h.symbolize_keys) ]
|
# [ :products, options.merge(params.permit(:page, :size).to_h.symbolize_keys) ]
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# In this instance the `params` object comes from the context in which the the
|
# In this instance the +params+ object comes from the context in which the the
|
||||||
# block is executed, e.g. generating a URL inside a controller action or a view.
|
# block is executed, e.g. generating a URL inside a controller action or a view.
|
||||||
# If the block is executed where there isn't a params object such as this:
|
# If the block is executed where there isn't a params object such as this:
|
||||||
#
|
#
|
||||||
# Rails.application.routes.url_helpers.browse_path
|
# Rails.application.routes.url_helpers.browse_path
|
||||||
#
|
#
|
||||||
# then it will raise a `NameError`. Because of this you need to be aware of the
|
# then it will raise a +NameError+. Because of this you need to be aware of the
|
||||||
# context in which you will use your custom URL helper when defining it.
|
# context in which you will use your custom URL helper when defining it.
|
||||||
#
|
#
|
||||||
# NOTE: The `direct` method can't be used inside of a scope block such as
|
# NOTE: The +direct+ method can't be used inside of a scope block such as
|
||||||
# `namespace` or `scope` and will raise an error if it detects that it is.
|
# +namespace+ or +scope+ and will raise an error if it detects that it is.
|
||||||
def direct(name, options = {}, &block)
|
def direct(name, options = {}, &block)
|
||||||
unless @scope.root?
|
unless @scope.root?
|
||||||
raise RuntimeError, "The direct method can't be used inside a routes scope block"
|
raise RuntimeError, "The direct method can't be used inside a routes scope block"
|
||||||
|
@ -2078,8 +2078,8 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
# Define custom polymorphic mappings of models to URLs. This alters the
|
# Define custom polymorphic mappings of models to URLs. This alters the
|
||||||
# behavior of `polymorphic_url` and consequently the behavior of
|
# behavior of +polymorphic_url+ and consequently the behavior of
|
||||||
# `link_to` and `form_for` when passed a model instance, e.g:
|
# +link_to+ and +form_for+ when passed a model instance, e.g:
|
||||||
#
|
#
|
||||||
# resource :basket
|
# resource :basket
|
||||||
#
|
#
|
||||||
|
@ -2087,8 +2087,8 @@ module ActionDispatch
|
||||||
# [:basket]
|
# [:basket]
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# This will now generate "/basket" when a `Basket` instance is passed to
|
# This will now generate "/basket" when a +Basket+ instance is passed to
|
||||||
# `link_to` or `form_for` instead of the standard "/baskets/:id".
|
# +link_to+ or +form_for+ instead of the standard "/baskets/:id".
|
||||||
#
|
#
|
||||||
# NOTE: This custom behavior only applies to simple polymorphic URLs where
|
# NOTE: This custom behavior only applies to simple polymorphic URLs where
|
||||||
# a single model instance is passed and not more complicated forms, e.g:
|
# a single model instance is passed and not more complicated forms, e.g:
|
||||||
|
@ -2105,7 +2105,7 @@ module ActionDispatch
|
||||||
# link_to "Profile", @current_user
|
# link_to "Profile", @current_user
|
||||||
# link_to "Profile", [:admin, @current_user]
|
# link_to "Profile", [:admin, @current_user]
|
||||||
#
|
#
|
||||||
# The first `link_to` will generate "/profile" but the second will generate
|
# The first +link_to+ will generate "/profile" but the second will generate
|
||||||
# the standard polymorphic URL of "/admin/users/1".
|
# the standard polymorphic URL of "/admin/users/1".
|
||||||
#
|
#
|
||||||
# You can pass options to a polymorphic mapping - the arity for the block
|
# You can pass options to a polymorphic mapping - the arity for the block
|
||||||
|
@ -2116,11 +2116,11 @@ module ActionDispatch
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# This generates the URL "/basket#items" because when the last item in an
|
# This generates the URL "/basket#items" because when the last item in an
|
||||||
# array passed to `polymorphic_url` is a hash then it's treated as options
|
# array passed to +polymorphic_url+ is a hash then it's treated as options
|
||||||
# to the URL helper that gets called.
|
# to the URL helper that gets called.
|
||||||
#
|
#
|
||||||
# NOTE: The `resolve` method can't be used inside of a scope block such as
|
# NOTE: The +resolve+ method can't be used inside of a scope block such as
|
||||||
# `namespace` or `scope` and will raise an error if it detects that it is.
|
# +namespace+ or +scope+ and will raise an error if it detects that it is.
|
||||||
def resolve(*args, &block)
|
def resolve(*args, &block)
|
||||||
unless @scope.root?
|
unless @scope.root?
|
||||||
raise RuntimeError, "The resolve method can't be used inside a routes scope block"
|
raise RuntimeError, "The resolve method can't be used inside a routes scope block"
|
||||||
|
|
Loading…
Reference in a new issue