1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

update syntax and add note about prompt use of HttpHelpers [ci-skip]

This commit is contained in:
Cesar Carruitero 2012-11-09 11:40:26 -05:00
parent 477cf3151a
commit d89b03a7c3

View file

@ -299,7 +299,7 @@ module ActionDispatch
# and +:action+ to the controller's action. A pattern can also map # and +:action+ to the controller's action. A pattern can also map
# wildcard segments (globs) to params: # wildcard segments (globs) to params:
# #
# match 'songs/*category/:title' => 'songs#show' # match 'songs/*category/:title', to: 'songs#show'
# #
# # 'songs/rock/classic/stairway-to-heaven' sets # # 'songs/rock/classic/stairway-to-heaven' sets
# # params[:category] = 'rock/classic' # # params[:category] = 'rock/classic'
@ -315,10 +315,14 @@ module ActionDispatch
# A pattern can also point to a +Rack+ endpoint i.e. anything that # A pattern can also point to a +Rack+ endpoint i.e. anything that
# responds to +call+: # responds to +call+:
# #
# match 'photos/:id' => lambda {|hash| [200, {}, "Coming soon"] } # match 'photos/:id', to: lambda {|hash| [200, {}, "Coming soon"] }
# match 'photos/:id' => PhotoRackApp # match 'photos/:id', to: PhotoRackApp
# # Yes, controller actions are just rack endpoints # # Yes, controller actions are just rack endpoints
# match 'photos/:id' => PhotosController.action(:show) # match 'photos/:id', to: PhotosController.action(:show)
#
# Because request various HTTP verbs with a single action has security
# implications, is recommendable use HttpHelpers[rdoc-ref:HttpHelpers]
# instead +match+
# #
# === Options # === Options
# #
@ -336,7 +340,7 @@ module ActionDispatch
# [:module] # [:module]
# The namespace for :controller. # The namespace for :controller.
# #
# match 'path' => 'c#a', module: 'sekret', controller: 'posts' # match 'path', to: 'c#a', module: 'sekret', controller: 'posts'
# #=> Sekret::PostsController # #=> Sekret::PostsController
# #
# See <tt>Scoping#namespace</tt> for its scope equivalent. # See <tt>Scoping#namespace</tt> for its scope equivalent.
@ -347,8 +351,9 @@ module ActionDispatch
# [:via] # [:via]
# Allowed HTTP verb(s) for route. # Allowed HTTP verb(s) for route.
# #
# match 'path' => 'c#a', via: :get # match 'path', to: 'c#a', via: :get
# match 'path' => 'c#a', via: [:get, :post] # match 'path', to: 'c#a', via: [:get, :post]
# match 'path', to: 'c#a', via: :all
# #
# [:to] # [:to]
# Points to a +Rack+ endpoint. Can be an object that responds to # Points to a +Rack+ endpoint. Can be an object that responds to
@ -364,14 +369,14 @@ module ActionDispatch
# <tt>resource(s)</tt> block. For example: # <tt>resource(s)</tt> block. For example:
# #
# resource :bar do # resource :bar do
# match 'foo' => 'c#a', on: :member, via: [:get, :post] # match 'foo', to: 'c#a', on: :member, via: [:get, :post]
# end # end
# #
# Is equivalent to: # Is equivalent to:
# #
# resource :bar do # resource :bar do
# member do # member do
# match 'foo' => 'c#a', via: [:get, :post] # match 'foo', to: 'c#a', via: [:get, :post]
# end # end
# end # end
# #
@ -384,7 +389,7 @@ module ActionDispatch
# class Blacklist # class Blacklist
# def matches?(request) request.remote_ip == '1.2.3.4' end # def matches?(request) request.remote_ip == '1.2.3.4' end
# end # end
# match 'path' => 'c#a', constraints: Blacklist.new # match 'path', to: 'c#a', constraints: Blacklist.new
# #
# See <tt>Scoping#constraints</tt> for more examples with its scope # See <tt>Scoping#constraints</tt> for more examples with its scope
# equivalent. # equivalent.
@ -393,7 +398,7 @@ module ActionDispatch
# Sets defaults for parameters # Sets defaults for parameters
# #
# # Sets params[:format] to 'jpg' by default # # Sets params[:format] to 'jpg' by default
# match 'path' => 'c#a', defaults: { format: 'jpg' } # match 'path', to: 'c#a', defaults: { format: 'jpg' }
# #
# See <tt>Scoping#defaults</tt> for its scope equivalent. # See <tt>Scoping#defaults</tt> for its scope equivalent.
# #
@ -402,7 +407,7 @@ module ActionDispatch
# false, the pattern matches any request prefixed with the given path. # false, the pattern matches any request prefixed with the given path.
# #
# # Matches any request starting with 'path' # # Matches any request starting with 'path'
# match 'path' => 'c#a', anchor: false # match 'path', to: 'c#a', anchor: false
# #
# [:format] # [:format]
# Allows you to specify the default value for optional +format+ # Allows you to specify the default value for optional +format+