Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:lifo/docrails

Conflicts:
	actionpack/lib/action_controller/metal/mime_responds.rb
	activerecord/lib/active_record/attribute_methods.rb
	guides/source/working_with_javascript_in_rails.md
  • Loading branch information...
commit 3b0bb08699ce409b8213c82956dc34086dcbc8b9 2 parents 974467d + ee91749
@vijaydev vijaydev authored
Showing with 873 additions and 809 deletions.
  1. +2 −2 actionpack/lib/action_controller/metal.rb
  2. +1 −1  actionpack/lib/action_controller/metal/conditional_get.rb
  3. +5 −5 actionpack/lib/action_controller/metal/data_streaming.rb
  4. +1 −1  actionpack/lib/action_controller/metal/force_ssl.rb
  5. +2 −2 actionpack/lib/action_controller/metal/head.rb
  6. +10 −10 actionpack/lib/action_controller/metal/http_authentication.rb
  7. +13 −13 actionpack/lib/action_controller/metal/mime_responds.rb
  8. +2 −2 actionpack/lib/action_controller/metal/params_wrapper.rb
  9. +11 −11 actionpack/lib/action_controller/metal/redirecting.rb
  10. +3 −3 actionpack/lib/action_controller/metal/renderers.rb
  11. +3 −3 actionpack/lib/action_controller/metal/request_forgery_protection.rb
  12. +10 −10 actionpack/lib/action_controller/metal/responder.rb
  13. +3 −3 actionpack/lib/action_controller/metal/streaming.rb
  14. +1 −1  actionpack/lib/action_controller/metal/strong_parameters.rb
  15. +1 −1  actionpack/lib/action_controller/metal/url_for.rb
  16. +11 −11 actionpack/lib/action_controller/test_case.rb
  17. +2 −2 actionpack/lib/action_dispatch/http/mime_type.rb
  18. +7 −7 actionpack/lib/action_dispatch/middleware/cookies.rb
  19. +2 −2 actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
  20. +2 −2 actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb
  21. +1 −1  actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb
  22. +2 −2 actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb
  23. +24 −24 actionpack/lib/action_dispatch/routing.rb
  24. +55 −55 actionpack/lib/action_dispatch/routing/mapper.rb
  25. +3 −3 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
  26. +4 −4 actionpack/lib/action_dispatch/routing/redirection.rb
  27. +6 −6 actionpack/lib/action_dispatch/routing/route_set.rb
  28. +15 −15 actionpack/lib/action_dispatch/routing/url_for.rb
  29. +3 −3 actionpack/lib/action_dispatch/testing/assertions/response.rb
  30. +15 −15 actionpack/lib/action_dispatch/testing/assertions/routing.rb
  31. +1 −1  actionpack/lib/action_dispatch/testing/assertions/selector.rb
  32. +19 −19 actionpack/lib/action_dispatch/testing/assertions/tag.rb
  33. +6 −6 actionpack/lib/action_dispatch/testing/integration.rb
  34. +2 −2 actionpack/lib/action_dispatch/testing/test_process.rb
  35. +1 −1  actionpack/lib/action_view/base.rb
  36. +32 −32 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  37. +6 −6 actionpack/lib/action_view/helpers/atom_feed_helper.rb
  38. +5 −5 actionpack/lib/action_view/helpers/capture_helper.rb
  39. +94 −94 actionpack/lib/action_view/helpers/date_helper.rb
  40. +1 −1  actionpack/lib/action_view/helpers/debug_helper.rb
  41. +22 −22 actionpack/lib/action_view/helpers/form_options_helper.rb
  42. +54 −54 actionpack/lib/action_view/helpers/form_tag_helper.rb
  43. +4 −4 actionpack/lib/action_view/helpers/javascript_helper.rb
  44. +56 −56 actionpack/lib/action_view/helpers/number_helper.rb
  45. +3 −3 actionpack/lib/action_view/helpers/record_tag_helper.rb
  46. +2 −2 actionpack/lib/action_view/helpers/rendering_helper.rb
  47. +1 −1  actionpack/lib/action_view/helpers/sanitize_helper.rb
  48. +7 −7 actionpack/lib/action_view/helpers/tag_helper.rb
  49. +22 −22 actionpack/lib/action_view/helpers/text_helper.rb
  50. +1 −1  actionpack/lib/action_view/helpers/translation_helper.rb
  51. +4 −4 actionpack/lib/action_view/helpers/url_helper.rb
  52. +27 −27 actionpack/lib/action_view/renderer/partial_renderer.rb
  53. +7 −7 actionpack/lib/action_view/routing_url_for.rb
  54. +12 −12 actionpack/lib/action_view/vendor/html-scanner/html/node.rb
  55. +16 −16 activemodel/lib/active_model/errors.rb
  56. +5 −5 activemodel/lib/active_model/validations.rb
  57. +2 −3 activemodel/lib/active_model/validations/acceptance.rb
  58. +1 −2  activemodel/lib/active_model/validations/confirmation.rb
  59. +1 −2  activemodel/lib/active_model/validations/exclusion.rb
  60. +1 −2  activemodel/lib/active_model/validations/format.rb
  61. +1 −2  activemodel/lib/active_model/validations/inclusion.rb
  62. +1 −2  activemodel/lib/active_model/validations/numericality.rb
  63. +0 −1  activemodel/lib/active_model/validations/presence.rb
  64. +5 −6 activemodel/lib/active_model/validations/validates.rb
  65. +1 −1  activemodel/lib/active_model/validations/with.rb
  66. +1 −1  activemodel/lib/active_model/validator.rb
  67. +12 −12 activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
  68. +1 −1  activemodel/test/cases/validations/validates_test.rb
  69. +1 −1  activerecord/lib/active_record/associations/association.rb
  70. +3 −3 activerecord/lib/active_record/associations/preloader.rb
  71. +1 −1  activerecord/lib/active_record/associations/singular_association.rb
  72. +1 −1  activerecord/lib/active_record/associations/through_association.rb
  73. +15 −10 activerecord/lib/active_record/attribute_methods.rb
  74. +43 −0 activerecord/lib/active_record/attribute_methods/before_type_cast.rb
  75. +6 −8 activerecord/lib/active_record/callbacks.rb
  76. +1 −1  activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  77. +21 −21 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  78. +24 −24 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  79. +2 −2 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
  80. +1 −1  activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
  81. +1 −1  activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
  82. +11 −0 activerecord/lib/active_record/errors.rb
  83. +1 −0  activerecord/lib/active_record/fixtures.rb
  84. +3 −3 activerecord/lib/active_record/nested_attributes.rb
  85. +9 −9 activerecord/lib/active_record/persistence.rb
  86. +12 −12 activerecord/lib/active_record/reflection.rb
  87. +5 −5 activerecord/lib/active_record/relation.rb
  88. +1 −1  activesupport/lib/active_support/core_ext/array/wrap.rb
  89. +3 −3 activesupport/lib/active_support/core_ext/hash/deep_merge.rb
  90. +3 −3 activesupport/lib/active_support/core_ext/hash/slice.rb
  91. +2 −2 activesupport/lib/active_support/core_ext/string/inflections.rb
  92. +4 −0 guides/source/3_1_release_notes.md
  93. +1 −1  guides/source/action_controller_overview.md
  94. +2 −2 guides/source/active_record_querying.md
  95. +2 −2 guides/source/active_record_validations_callbacks.md
  96. +18 −18 guides/source/active_support_core_extensions.md
  97. +2 −2 guides/source/active_support_instrumentation.md
  98. +3 −0  guides/source/asset_pipeline.md
  99. +1 −1  guides/source/configuring.md
  100. +1 −0  guides/source/contributing_to_ruby_on_rails.md
  101. +1 −1  guides/source/i18n.md
  102. +3 −3 guides/source/layouts_and_rendering.md
  103. +3 −2 guides/source/migrations.md
  104. +4 −0 guides/source/upgrading_ruby_on_rails.md
  105. +1 −0  guides/source/working_with_javascript_in_rails.md
View
4 actionpack/lib/action_controller/metal.rb
@@ -5,7 +5,7 @@ module ActionController
# allowing the following syntax in controllers:
#
# class PostsController < ApplicationController
- # use AuthenticationMiddleware, :except => [:index, :show]
+ # use AuthenticationMiddleware, except: [:index, :show]
# end
#
class MiddlewareStack < ActionDispatch::MiddlewareStack #:nodoc:
@@ -56,7 +56,7 @@ def build(action, app=nil, &block)
# And then to route requests to your metal controller, you would add
# something like this to <tt>config/routes.rb</tt>:
#
- # match 'hello', :to => HelloController.action(:index)
+ # match 'hello', to: HelloController.action(:index)
#
# The +action+ method returns a valid Rack application for the \Rails
# router to dispatch to.
View
2  actionpack/lib/action_controller/metal/conditional_get.rb
@@ -64,7 +64,7 @@ def etag(&etagger)
#
# def show
# @article = Article.find(params[:id])
- # fresh_when(@article, :public => true)
+ # fresh_when(@article, public: true)
# end
def fresh_when(record_or_options, additional_options = {})
if record_or_options.is_a? Hash
View
10 actionpack/lib/action_controller/metal/data_streaming.rb
@@ -47,11 +47,11 @@ module DataStreaming
#
# Show a JPEG in the browser:
#
- # send_file '/path/to.jpeg', :type => 'image/jpeg', :disposition => 'inline'
+ # send_file '/path/to.jpeg', type: 'image/jpeg', disposition: 'inline'
#
# Show a 404 page in the browser:
#
- # send_file '/path/to/404.html', :type => 'text/html; charset=utf-8', :status => 404
+ # send_file '/path/to/404.html', type: 'text/html; charset=utf-8', status: 404
#
# Read about the other Content-* HTTP headers if you'd like to
# provide the user with more information (such as Content-Description) in
@@ -96,7 +96,7 @@ def each
end
# Sends the given binary data to the browser. This method is similar to
- # <tt>render :text => data</tt>, but also allows you to specify whether
+ # <tt>render text: data</tt>, but also allows you to specify whether
# the browser should display the response as a file attachment (i.e. in a
# download dialog) or as inline data. You may also set the content type,
# the apparent file name, and other things.
@@ -117,11 +117,11 @@ def each
#
# Download a dynamically-generated tarball:
#
- # send_data generate_tgz('dir'), :filename => 'dir.tgz'
+ # send_data generate_tgz('dir'), filename: 'dir.tgz'
#
# Display an image Active Record in the browser:
#
- # send_data image.data, :type => image.content_type, :disposition => 'inline'
+ # send_data image.data, type: image.content_type, disposition: 'inline'
#
# See +send_file+ for more information on HTTP Content-* headers and caching.
def send_data(data, options = {}) #:doc:
View
2  actionpack/lib/action_controller/metal/force_ssl.rb
@@ -22,7 +22,7 @@ module ClassMethods
# an +:if+ or +:unless+ condition.
#
# class AccountsController < ApplicationController
- # force_ssl :if => :ssl_configured?
+ # force_ssl if: :ssl_configured?
#
# def ssl_configured?
# !Rails.env.development?
View
4 actionpack/lib/action_controller/metal/head.rb
@@ -7,9 +7,9 @@ module Head
# This allows you to easily return a response that consists only of
# significant headers:
#
- # head :created, :location => person_path(@person)
+ # head :created, location: person_path(@person)
#
- # head :created, :location => @person
+ # head :created, location: @person
#
# It can also be used to return exceptional conditions:
#
View
20 actionpack/lib/action_controller/metal/http_authentication.rb
@@ -8,14 +8,14 @@ module HttpAuthentication
# === Simple \Basic example
#
# class PostsController < ApplicationController
- # http_basic_authenticate_with :name => "dhh", :password => "secret", :except => :index
+ # http_basic_authenticate_with name: "dhh", password: "secret", except: :index
#
# def index
- # render :text => "Everyone can see me!"
+ # render text: "Everyone can see me!"
# end
#
# def edit
- # render :text => "I'm only accessible if you know the password"
+ # render text: "I'm only accessible if you know the password"
# end
# end
#
@@ -124,14 +124,14 @@ def authentication_request(controller, realm)
# USERS = {"dhh" => "secret", #plain text password
# "dap" => Digest::MD5.hexdigest(["dap",REALM,"secret"].join(":"))} #ha1 digest password
#
- # before_filter :authenticate, :except => [:index]
+ # before_filter :authenticate, except: [:index]
#
# def index
- # render :text => "Everyone can see me!"
+ # render text: "Everyone can see me!"
# end
#
# def edit
- # render :text => "I'm only accessible if you know the password"
+ # render text: "I'm only accessible if you know the password"
# end
#
# private
@@ -317,14 +317,14 @@ def opaque(secret_key)
# class PostsController < ApplicationController
# TOKEN = "secret"
#
- # before_filter :authenticate, :except => [ :index ]
+ # before_filter :authenticate, except: [ :index ]
#
# def index
- # render :text => "Everyone can see me!"
+ # render text: "Everyone can see me!"
# end
#
# def edit
- # render :text => "I'm only accessible if you know the password"
+ # render text: "I'm only accessible if you know the password"
# end
#
# private
@@ -424,7 +424,7 @@ def authenticate(controller, &login_procedure)
# Parses the token and options out of the token authorization header. If
# the header looks like this:
# Authorization: Token token="abc", nonce="def"
- # Then the returned token is "abc", and the options is {:nonce => "def"}
+ # Then the returned token is "abc", and the options is {nonce: "def"}
#
# request - ActionDispatch::Request instance with the current headers.
#
View
26 actionpack/lib/action_controller/metal/mime_responds.rb
@@ -23,13 +23,13 @@ module ClassMethods
# <tt>:except</tt> with an array of actions or a single action:
#
# respond_to :html
- # respond_to :xml, :json, :except => [ :edit ]
+ # respond_to :xml, :json, except: [ :edit ]
#
# This specifies that all actions respond to <tt>:html</tt>
# and all actions except <tt>:edit</tt> respond to <tt>:xml</tt> and
# <tt>:json</tt>.
#
- # respond_to :json, :only => :create
+ # respond_to :json, only: :create
#
# This specifies that the <tt>:create</tt> action and no other responds
# to <tt>:json</tt>.
@@ -70,7 +70,7 @@ def clear_respond_to
#
# respond_to do |format|
# format.html
- # format.xml { render :xml => @people }
+ # format.xml { render xml: @people }
# end
# end
#
@@ -98,7 +98,7 @@ def clear_respond_to
# respond_to do |format|
# format.html { redirect_to(person_list_url) }
# format.js
- # format.xml { render :xml => @person.to_xml(:include => @company) }
+ # format.xml { render xml: @person.to_xml(include: @company) }
# end
# end
#
@@ -162,11 +162,11 @@ def clear_respond_to
#
# In the example above, if the format is xml, it will render:
#
- # render :xml => @people
+ # render xml: @people
#
# Or if the format is json:
#
- # render :json => @people
+ # render json: @people
#
# Since this is a common pattern, you can use the class method respond_to
# with the respond_with method to have the same results:
@@ -246,10 +246,10 @@ def respond_to(*mimes, &block)
# if @user.save
# flash[:notice] = 'User was successfully created.'
# format.html { redirect_to(@user) }
- # format.xml { render :xml => @user }
+ # format.xml { render xml: @user }
# else
- # format.html { render :action => "new" }
- # format.xml { render :xml => @user }
+ # format.html { render action: "new" }
+ # format.xml { render xml: @user }
# end
# end
# end
@@ -259,8 +259,8 @@ def respond_to(*mimes, &block)
# * for other requests - i.e. data formats such as xml, json, csv etc, if
# the resource passed to +respond_with+ responds to <code>to_<format></code>,
# the method attempts to render the resource in the requested format
- # directly, e.g. for an xml request, the response is equivalent to calling
- # <code>render :xml => resource</code>.
+ # directly, e.g. for an xml request, the response is equivalent to calling
+ # <code>render xml: resource</code>.
#
# === Nested resources
#
@@ -309,7 +309,7 @@ def respond_to(*mimes, &block)
# Also, a hash passed to +respond_with+ immediately after the specified
# resource(s) is interpreted as a set of options relevant to all
# formats. Any option accepted by +render+ can be used, e.g.
- # respond_with @people, :status => 200
+ # respond_with @people, status: 200
# However, note that these options are ignored after an unsuccessful attempt
# to save a resource, e.g. when automatically rendering <tt>:new</tt>
# after a post request.
@@ -381,7 +381,7 @@ def retrieve_collector_from_mimes(mimes=nil, &block) #:nodoc:
#
# respond_to do |format|
# format.html
- # format.xml { render :xml => @people }
+ # format.xml { render xml: @people }
# end
#
# In this usage, the argument passed to the block (+format+ above) is an
View
4 actionpack/lib/action_controller/metal/params_wrapper.rb
@@ -82,7 +82,7 @@ module ClassMethods
# would use to determine the attribute names from.
#
# ==== Examples
- # wrap_parameters :format => :xml
+ # wrap_parameters format: :xml
# # enables the parameter wrapper for XML format
#
# wrap_parameters :person
@@ -92,7 +92,7 @@ module ClassMethods
# # wraps parameters by determining the wrapper key from Person class
# (+person+, in this case) and the list of attribute names
#
- # wrap_parameters :include => [:username, :title]
+ # wrap_parameters include: [:username, :title]
# # wraps only +:username+ and +:title+ attributes from parameters.
#
# wrap_parameters false
View
22 actionpack/lib/action_controller/metal/redirecting.rb
@@ -24,7 +24,7 @@ module Redirecting
# * <tt>:back</tt> - Back to the page that issued the request. Useful for forms that are triggered from multiple places.
# Short-hand for <tt>redirect_to(request.env["HTTP_REFERER"])</tt>
#
- # redirect_to :action => "show", :id => 5
+ # redirect_to action: "show", id: 5
# redirect_to post
# redirect_to "http://www.rubyonrails.org"
# redirect_to "/images/screenshot.jpg"
@@ -34,10 +34,10 @@ module Redirecting
#
# The redirection happens as a "302 Moved" header unless otherwise specified.
#
- # redirect_to post_url(@post), :status => :found
- # redirect_to :action=>'atom', :status => :moved_permanently
- # redirect_to post_url(@post), :status => 301
- # redirect_to :action=>'atom', :status => 302
+ # redirect_to post_url(@post), status: :found
+ # redirect_to action: 'atom', status: :moved_permanently
+ # redirect_to post_url(@post), status: 301
+ # redirect_to action: 'atom', status: 302
#
# The status code can either be a standard {HTTP Status code}[http://www.iana.org/assignments/http-status-codes] as an
# integer, or a symbol representing the downcased, underscored and symbolized description.
@@ -49,16 +49,16 @@ module Redirecting
# around this you can return a <tt>303 See Other</tt> status code which will be
# followed using a GET request.
#
- # redirect_to posts_url, :status => :see_other
- # redirect_to :action => 'index', :status => 303
+ # redirect_to posts_url, status: :see_other
+ # redirect_to action: 'index', status: 303
#
# It is also possible to assign a flash message as part of the redirection. There are two special accessors for the commonly used flash names
# +alert+ and +notice+ as well as a general purpose +flash+ bucket.
#
- # redirect_to post_url(@post), :alert => "Watch it, mister!"
- # redirect_to post_url(@post), :status=> :found, :notice => "Pay attention to the road"
- # redirect_to post_url(@post), :status => 301, :flash => { :updated_post_id => @post.id }
- # redirect_to { :action=>'atom' }, :alert => "Something serious happened"
+ # redirect_to post_url(@post), alert: "Watch it, mister!"
+ # redirect_to post_url(@post), status: :found, notice: "Pay attention to the road"
+ # redirect_to post_url(@post), status: 301, flash: { updated_post_id: @post.id }
+ # redirect_to { action: 'atom' }, alert: "Something serious happened"
#
# When using <tt>redirect_to :back</tt>, if there is no referrer, ActionController::RedirectBackError will be raised. You may specify some fallback
# behavior for this case by rescuing ActionController::RedirectBackError.
View
6 actionpack/lib/action_controller/metal/renderers.rb
@@ -52,8 +52,8 @@ def _handle_render_options(options)
# ActionController::Renderers.add :csv do |obj, options|
# filename = options[:filename] || 'data'
# str = obj.respond_to?(:to_csv) ? obj.to_csv : obj.to_s
- # send_data str, :type => Mime::CSV,
- # :disposition => "attachment; filename=#{filename}.csv"
+ # send_data str, type: Mime::CSV,
+ # disposition: "attachment; filename=#{filename}.csv"
# end
#
# Note that we used Mime::CSV for the csv mime type as it comes with Rails.
@@ -66,7 +66,7 @@ def _handle_render_options(options)
# @csvable = Csvable.find(params[:id])
# respond_to do |format|
# format.html
- # format.csv { render :csv => @csvable, :filename => @csvable.name }
+ # format.csv { render csv: @csvable, filename: @csvable.name }
# }
# end
# To use renderers and their mime types in more concise ways, see
View
6 actionpack/lib/action_controller/metal/request_forgery_protection.rb
@@ -19,7 +19,7 @@ class InvalidAuthenticityToken < ActionControllerError #:nodoc:
#
# class ApplicationController < ActionController::Base
# protect_from_forgery
- # skip_before_filter :verify_authenticity_token, :if => :json_request?
+ # skip_before_filter :verify_authenticity_token, if: :json_request?
#
# protected
#
@@ -62,7 +62,7 @@ module ClassMethods
# Turn on request forgery protection. Bear in mind that only non-GET, HTML/JavaScript requests are checked.
#
# class FooController < ApplicationController
- # protect_from_forgery :except => :index
+ # protect_from_forgery except: :index
#
# You can disable csrf protection on controller-by-controller basis:
#
@@ -70,7 +70,7 @@ module ClassMethods
#
# It can also be disabled for specific controller actions:
#
- # skip_before_filter :verify_authenticity_token, :except => [:create]
+ # skip_before_filter :verify_authenticity_token, except: [:create]
#
# Valid Options:
#
View
20 actionpack/lib/action_controller/metal/responder.rb
@@ -45,10 +45,10 @@ module ActionController #:nodoc:
# if @user.save
# flash[:notice] = 'User was successfully created.'
# format.html { redirect_to(@user) }
- # format.xml { render :xml => @user, :status => :created, :location => @user }
+ # format.xml { render xml: @user, status: :created, location: @user }
# else
- # format.html { render :action => "new" }
- # format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
+ # format.html { render action: "new" }
+ # format.xml { render xml: @user.errors, status: :unprocessable_entity }
# end
# end
# end
@@ -92,7 +92,7 @@ module ActionController #:nodoc:
# @project = Project.find(params[:project_id])
# @task = @project.tasks.build(params[:task])
# flash[:notice] = 'Task was successfully created.' if @task.save
- # respond_with(@project, @task, :status => 201)
+ # respond_with(@project, @task, status: 201)
# end
#
# This will return status 201 if the task was saved successfully. If not,
@@ -103,7 +103,7 @@ module ActionController #:nodoc:
# def create
# @project = Project.find(params[:project_id])
# @task = @project.tasks.build(params[:task])
- # respond_with(@project, @task, :status => 201) do |format|
+ # respond_with(@project, @task, status: 201) do |format|
# if @task.save
# flash[:notice] = 'Task was successfully created.'
# else
@@ -236,20 +236,20 @@ def default_render
# Display is just a shortcut to render a resource with the current format.
#
- # display @user, :status => :ok
+ # display @user, status: :ok
#
# For XML requests it's equivalent to:
#
- # render :xml => @user, :status => :ok
+ # render xml: @user, status: :ok
#
# Options sent by the user are also used:
#
- # respond_with(@user, :status => :created)
- # display(@user, :status => :ok)
+ # respond_with(@user, status: :created)
+ # display(@user, status: :ok)
#
# Results in:
#
- # render :xml => @user, :status => :created
+ # render xml: @user, status: :created
#
def display(resource, given_options={})
controller.render given_options.merge!(options).merge!(format => resource)
View
6 actionpack/lib/action_controller/metal/streaming.rb
@@ -29,7 +29,7 @@ module ActionController #:nodoc:
# class PostsController
# def index
# @posts = Post.scoped
- # render :stream => true
+ # render stream: true
# end
# end
#
@@ -56,7 +56,7 @@ module ActionController #:nodoc:
# @posts = Post.scoped
# @pages = Page.scoped
# @articles = Article.scoped
- # render :stream => true
+ # render stream: true
# end
#
# Notice that :stream only works with templates. Rendering :json
@@ -176,7 +176,7 @@ module ActionController #:nodoc:
# need to create a config file as follow:
#
# # unicorn.config.rb
- # listen 3000, :tcp_nopush => false
+ # listen 3000, tcp_nopush: false
#
# And use it on initialization:
#
View
2  actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -361,7 +361,7 @@ def each_element(object)
# # It's mandatory to specify the nested attributes that should be whitelisted.
# # If you use `permit` with just the key that points to the nested attributes hash,
# # it will return an empty hash.
- # params.require(:person).permit(:name, :age, pets_attributes: { :name, :category })
+ # params.require(:person).permit(:name, :age, pets_attributes: [ :name, :category ])
# end
# end
#
View
2  actionpack/lib/action_controller/metal/url_for.rb
@@ -10,7 +10,7 @@ module ActionController
# include ActionController::UrlFor
# include Rails.application.routes.url_helpers
#
- # delegate :env, :request, :to => :controller
+ # delegate :env, :request, to: :controller
#
# def initialize(controller)
# @controller = controller
View
22 actionpack/lib/action_controller/test_case.rb
@@ -61,25 +61,25 @@ def process(*args)
# assert_template %r{\Aadmin/posts/new\Z}
#
# # assert that the layout 'admin' was rendered
- # assert_template :layout => 'admin'
- # assert_template :layout => 'layouts/admin'
- # assert_template :layout => :admin
+ # assert_template layout: 'admin'
+ # assert_template layout: 'layouts/admin'
+ # assert_template layout: :admin
#
# # assert that no layout was rendered
- # assert_template :layout => nil
- # assert_template :layout => false
+ # assert_template layout: nil
+ # assert_template layout: false
#
# # assert that the "_customer" partial was rendered twice
- # assert_template :partial => '_customer', :count => 2
+ # assert_template partial: '_customer', count: 2
#
# # assert that no partials were rendered
- # assert_template :partial => false
+ # assert_template partial: false
#
# In a view test case, you can also assert that specific locals are passed
# to partials:
#
# # assert that the "_customer" partial was rendered with a specific object
- # assert_template :partial => '_customer', :locals => { :customer => @customer }
+ # assert_template partial: '_customer', locals: { customer: @customer }
def assert_template(options = {}, message = nil)
# Force body to be read in case the
# template is being streamed
@@ -267,7 +267,7 @@ def exists?
# class BooksControllerTest < ActionController::TestCase
# def test_create
# # Simulate a POST response with the given HTTP parameters.
- # post(:create, :book => { :title => "Love Hina" })
+ # post(:create, book: { title: "Love Hina" })
#
# # Assert that the controller tried to redirect us to
# # the created book's URI.
@@ -281,7 +281,7 @@ def exists?
# You can also send a real document in the simulated HTTP request.
#
# def test_create
- # json = {:book => { :title => "Love Hina" }}.to_json
+ # json = {book: { title: "Love Hina" }}.to_json
# post :create, json
# end
#
@@ -356,7 +356,7 @@ def exists?
#
# If you're using named routes, they can be easily tested using the original named routes' methods straight in the test case.
#
- # assert_redirected_to page_url(:title => 'foo')
+ # assert_redirected_to page_url(title: 'foo')
class TestCase < ActiveSupport::TestCase
# Use AC::TestCase for the base class when describing a controller
View
4 actionpack/lib/action_dispatch/http/mime_type.rb
@@ -44,8 +44,8 @@ def fetch(type)
#
# respond_to do |format|
# format.html
- # format.ics { render :text => post.to_ics, :mime_type => Mime::Type["text/calendar"] }
- # format.xml { render :xml => @people }
+ # format.ics { render text: post.to_ics, mime_type: Mime::Type["text/calendar"] }
+ # format.xml { render xml: @people }
# end
# end
# end
View
14 actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -24,7 +24,7 @@ def cookie_jar
# cookies[:lat_lon] = [47.68, -122.37]
#
# # Sets a cookie that expires in 1 hour.
- # cookies[:login] = { :value => "XJ-122", :expires => 1.hour.from_now }
+ # cookies[:login] = { value: "XJ-122", expires: 1.hour.from_now }
#
# # Sets a signed cookie, which prevents users from tampering with its value.
# # The cookie is signed by your app's <tt>config.secret_token</tt> value.
@@ -51,12 +51,12 @@ def cookie_jar
# Please note that if you specify a :domain when setting a cookie, you must also specify the domain when deleting the cookie:
#
# cookies[:key] = {
- # :value => 'a yummy cookie',
- # :expires => 1.year.from_now,
- # :domain => 'domain.com'
+ # value: 'a yummy cookie',
+ # expires: 1.year.from_now,
+ # domain: 'domain.com'
# }
#
- # cookies.delete(:key, :domain => 'domain.com')
+ # cookies.delete(:key, domain: 'domain.com')
#
# The option symbols for setting cookies are:
#
@@ -69,8 +69,8 @@ def cookie_jar
# to <tt>:all</tt>. Make sure to specify the <tt>:domain</tt> option with
# <tt>:all</tt> again when deleting keys.
#
- # :domain => nil # Does not sets cookie domain. (default)
- # :domain => :all # Allow the cookie for the top most level
+ # domain: nil # Does not sets cookie domain. (default)
+ # domain: :all # Allow the cookie for the top most level
# domain and subdomains.
#
# * <tt>:expires</tt> - The time at which this cookie expires, as a \Time object.
View
4 actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
@@ -28,8 +28,8 @@ module Session
# a secret consisting of random numbers and letters and more than 30
# characters.
#
- # :secret => '449fe2e7daee471bffae2fd8dc02313d'
- # :secret => Proc.new { User.current_user.secret_key }
+ # secret: '449fe2e7daee471bffae2fd8dc02313d'
+ # secret: Proc.new { User.current_user.secret_key }
#
# * <tt>:digest</tt>: The message digest algorithm used to verify session
# integrity defaults to 'SHA1' but may be any digest provided by OpenSSL,
View
4 actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb
@@ -6,5 +6,5 @@
</h1>
<pre><%=h @exception.message %></pre>
-<%= render :template => "rescues/_trace" %>
-<%= render :template => "rescues/_request_and_response" %>
+<%= render template: "rescues/_trace" %>
+<%= render template: "rescues/_request_and_response" %>
View
2  actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb
@@ -10,7 +10,7 @@
</ol>
</p>
<% end %>
-<%= render :template => "rescues/_trace" %>
+<%= render template: "rescues/_trace" %>
<h2>
Routes
View
4 actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb
@@ -13,5 +13,5 @@
<p><%=h @exception.sub_template_message %></p>
-<%= render :template => "rescues/_trace" %>
-<%= render :template => "rescues/_request_and_response" %>
+<%= render template: "rescues/_trace" %>
+<%= render template: "rescues/_request_and_response" %>
View
48 actionpack/lib/action_dispatch/routing.rb
@@ -61,7 +61,7 @@ module ActionDispatch
# directory by using +scope+. +scope+ takes additional options which
# apply to all enclosed routes.
#
- # scope :path => "/cpanel", :as => 'admin' do
+ # scope path: "/cpanel", as: 'admin' do
# resources :posts, :comments
# end
#
@@ -78,22 +78,22 @@ module ActionDispatch
# Example:
#
# # In routes.rb
- # match '/login' => 'accounts#login', :as => 'login'
+ # match '/login' => 'accounts#login', as: 'login'
#
# # With render, redirect_to, tests, etc.
# redirect_to login_url
#
# Arguments can be passed as well.
#
- # redirect_to show_item_path(:id => 25)
+ # redirect_to show_item_path(id: 25)
#
# Use <tt>root</tt> as a shorthand to name a route for the root path "/".
#
# # In routes.rb
- # root :to => 'blogs#index'
+ # root to: 'blogs#index'
#
# # would recognize http://www.example.com/ as
- # params = { :controller => 'blogs', :action => 'index' }
+ # params = { controller: 'blogs', action: 'index' }
#
# # and provide these named routes
# root_url # => 'http://www.example.com/'
@@ -110,43 +110,43 @@ module ActionDispatch
# end
#
# # provides named routes for show, delete, and edit
- # link_to @article.title, show_path(:id => @article.id)
+ # link_to @article.title, show_path(id: @article.id)
#
# == Pretty URLs
#
# Routes can generate pretty URLs. For example:
#
- # match '/articles/:year/:month/:day' => 'articles#find_by_id', :constraints => {
- # :year => /\d{4}/,
- # :month => /\d{1,2}/,
- # :day => /\d{1,2}/
+ # match '/articles/:year/:month/:day' => 'articles#find_by_id', constraints: {
+ # year: /\d{4}/,
+ # month: /\d{1,2}/,
+ # day: /\d{1,2}/
# }
#
# Using the route above, the URL "http://localhost:3000/articles/2005/11/06"
# maps to
#
- # params = {:year => '2005', :month => '11', :day => '06'}
+ # params = {year: '2005', month: '11', day: '06'}
#
# == Regular Expressions and parameters
# You can specify a regular expression to define a format for a parameter.
#
# controller 'geocode' do
- # match 'geocode/:postalcode' => :show, :constraints => {
- # :postalcode => /\d{5}(-\d{4})?/
+ # match 'geocode/:postalcode' => :show, constraints: {
+ # postalcode: /\d{5}(-\d{4})?/
# }
#
# Constraints can include the 'ignorecase' and 'extended syntax' regular
# expression modifiers:
#
# controller 'geocode' do
- # match 'geocode/:postalcode' => :show, :constraints => {
- # :postalcode => /hx\d\d\s\d[a-z]{2}/i
+ # match 'geocode/:postalcode' => :show, constraints: {
+ # postalcode: /hx\d\d\s\d[a-z]{2}/i
# }
# end
#
# controller 'geocode' do
- # match 'geocode/:postalcode' => :show, :constraints => {
- # :postalcode => /# Postcode format
+ # match 'geocode/:postalcode' => :show, constraints: {
+ # postalcode: /# Postcode format
# \d{5} #Prefix
# (-\d{4})? #Suffix
# /x
@@ -172,9 +172,9 @@ module ActionDispatch
# Suppose you get an incoming request for <tt>/blog/edit/22</tt>, you'll end
# up with:
#
- # params = { :controller => 'blog',
- # :action => 'edit',
- # :id => '22'
+ # params = { controller: 'blog',
+ # action: 'edit',
+ # id: '22'
# }
#
# By not relying on default routes, you improve the security of your
@@ -193,8 +193,8 @@ module ActionDispatch
#
# Examples:
#
- # match 'post/:id' => 'posts#show', :via => :get
- # match 'post/:id' => 'posts#create_comment', :via => :post
+ # match 'post/:id' => 'posts#show', via: :get
+ # match 'post/:id' => 'posts#create_comment', via: :post
#
# Now, if you POST to <tt>/posts/:id</tt>, it will route to the <tt>create_comment</tt> action. A GET on the same
# URL will route to the <tt>show</tt> action.
@@ -249,7 +249,7 @@ module ActionDispatch
# === +assert_routing+
#
# def test_movie_route_properly_splits
- # opts = {:controller => "plugin", :action => "checkout", :id => "2"}
+ # opts = {controller: "plugin", action: "checkout", id: "2"}
# assert_routing "plugin/checkout/2", opts
# end
#
@@ -258,7 +258,7 @@ module ActionDispatch
# === +assert_recognizes+
#
# def test_route_has_options
- # opts = {:controller => "plugin", :action => "show", :id => "12"}
+ # opts = {controller: "plugin", action: "show", id: "12"}
# assert_recognizes opts, "/plugins/show/12"
# end
#
View
110 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -121,7 +121,7 @@ def normalize_path(path)
# Add a default constraint for :controller path segments that matches namespaced
# controllers with default routes like :controller/:action/:id(.:format), e.g:
# GET /admin/products/show/1
- # => { :controller => 'admin/products', :action => 'show', :id => '1' }
+ # => { controller: 'admin/products', action: 'show', id: '1' }
@options[:controller] ||= /.+?/
end
@@ -272,7 +272,7 @@ def self.normalize_name(name)
module Base
# You can specify what Rails should route "/" to with the root method:
#
- # root :to => 'pages#main'
+ # root to: 'pages#main'
#
# For options, see +match+, as +root+ uses it internally.
#
@@ -309,8 +309,8 @@ def root(options = {})
# +:controller+ should be set in options or hash shorthand. Examples:
#
# match 'photos/:id' => 'photos#show'
- # match 'photos/:id', :to => 'photos#show'
- # match 'photos/:id', :controller => 'photos', :action => 'show'
+ # match 'photos/:id', to: 'photos#show'
+ # match 'photos/:id', controller: 'photos', action: 'show'
#
# A pattern can also point to a +Rack+ endpoint i.e. anything that
# responds to +call+:
@@ -336,7 +336,7 @@ def root(options = {})
# [:module]
# The namespace for :controller.
#
- # match 'path' => 'c#a', :module => 'sekret', :controller => 'posts'
+ # match 'path' => 'c#a', module: 'sekret', controller: 'posts'
# #=> Sekret::PostsController
#
# See <tt>Scoping#namespace</tt> for its scope equivalent.
@@ -347,16 +347,16 @@ def root(options = {})
# [:via]
# Allowed HTTP verb(s) for route.
#
- # match 'path' => 'c#a', :via => :get
- # match 'path' => 'c#a', :via => [:get, :post]
+ # match 'path' => 'c#a', via: :get
+ # match 'path' => 'c#a', via: [:get, :post]
#
# [:to]
# Points to a +Rack+ endpoint. Can be an object that responds to
# +call+ or a string representing a controller's action.
#
- # match 'path', :to => 'controller#action'
- # match 'path', :to => lambda { |env| [200, {}, "Success!"] }
- # match 'path', :to => RackApp
+ # match 'path', to: 'controller#action'
+ # match 'path', to: lambda { |env| [200, {}, "Success!"] }
+ # match 'path', to: RackApp
#
# [:on]
# Shorthand for wrapping routes in a specific RESTful context. Valid
@@ -364,14 +364,14 @@ def root(options = {})
# <tt>resource(s)</tt> block. For example:
#
# resource :bar do
- # match 'foo' => 'c#a', :on => :member, :via => [:get, :post]
+ # match 'foo' => 'c#a', on: :member, via: [:get, :post]
# end
#
# Is equivalent to:
#
# resource :bar do
# member do
- # match 'foo' => 'c#a', :via => [:get, :post]
+ # match 'foo' => 'c#a', via: [:get, :post]
# end
# end
#
@@ -379,12 +379,12 @@ def root(options = {})
# Constrains parameters with a hash of regular expressions or an
# object that responds to <tt>matches?</tt>
#
- # match 'path/:id', :constraints => { :id => /[A-Z]\d{5}/ }
+ # match 'path/:id', constraints: { id: /[A-Z]\d{5}/ }
#
# class Blacklist
# def matches?(request) request.remote_ip == '1.2.3.4' end
# end
- # match 'path' => 'c#a', :constraints => Blacklist.new
+ # match 'path' => 'c#a', constraints: Blacklist.new
#
# See <tt>Scoping#constraints</tt> for more examples with its scope
# equivalent.
@@ -393,7 +393,7 @@ def root(options = {})
# Sets defaults for parameters
#
# # Sets params[:format] to 'jpg' by default
- # match 'path' => 'c#a', :defaults => { :format => 'jpg' }
+ # match 'path' => 'c#a', defaults: { format: 'jpg' }
#
# See <tt>Scoping#defaults</tt> for its scope equivalent.
#
@@ -402,7 +402,7 @@ def root(options = {})
# false, the pattern matches any request prefixed with the given path.
#
# # Matches any request starting with 'path'
- # match 'path' => 'c#a', :anchor => false
+ # match 'path' => 'c#a', anchor: false
#
# [:format]
# Allows you to specify the default value for optional +format+
@@ -412,7 +412,7 @@ def match(path, options=nil)
# Mount a Rack-based application to be used within the application.
#
- # mount SomeRackApp, :at => "some_route"
+ # mount SomeRackApp, at: "some_route"
#
# Alternatively:
#
@@ -425,7 +425,7 @@ def match(path, options=nil)
# the helper is either +some_rack_app_path+ or +some_rack_app_url+.
# To customize this helper's name, use the +:as+ option:
#
- # mount(SomeRackApp => "some_route", :as => "exciting")
+ # mount(SomeRackApp => "some_route", as: "exciting")
#
# This will generate the +exciting_path+ and +exciting_url+ helpers
# which can be used to navigate to this mounted app.
@@ -503,7 +503,7 @@ module HttpHelpers
# Define a route that only recognizes HTTP GET.
# For supported arguments, see <tt>Base#match</tt>.
#
- # get 'bacon', :to => 'food#bacon'
+ # get 'bacon', to: 'food#bacon'
def get(*args, &block)
map_method(:get, args, &block)
end
@@ -511,7 +511,7 @@ def get(*args, &block)
# Define a route that only recognizes HTTP POST.
# For supported arguments, see <tt>Base#match</tt>.
#
- # post 'bacon', :to => 'food#bacon'
+ # post 'bacon', to: 'food#bacon'
def post(*args, &block)
map_method(:post, args, &block)
end
@@ -519,7 +519,7 @@ def post(*args, &block)
# Define a route that only recognizes HTTP PATCH.
# For supported arguments, see <tt>Base#match</tt>.
#
- # patch 'bacon', :to => 'food#bacon'
+ # patch 'bacon', to: 'food#bacon'
def patch(*args, &block)
map_method(:patch, args, &block)
end
@@ -527,7 +527,7 @@ def patch(*args, &block)
# Define a route that only recognizes HTTP PUT.
# For supported arguments, see <tt>Base#match</tt>.
#
- # put 'bacon', :to => 'food#bacon'
+ # put 'bacon', to: 'food#bacon'
def put(*args, &block)
map_method(:put, args, &block)
end
@@ -535,7 +535,7 @@ def put(*args, &block)
# Define a route that only recognizes HTTP DELETE.
# For supported arguments, see <tt>Base#match</tt>.
#
- # delete 'broccoli', :to => 'food#broccoli'
+ # delete 'broccoli', to: 'food#broccoli'
def delete(*args, &block)
map_method(:delete, args, &block)
end
@@ -574,13 +574,13 @@ def map_method(method, args, &block)
# If you want to route /posts (without the prefix /admin) to
# <tt>Admin::PostsController</tt>, you could use
#
- # scope :module => "admin" do
+ # scope module: "admin" do
# resources :posts
# end
#
# or, for a single case
#
- # resources :posts, :module => "admin"
+ # resources :posts, module: "admin"
#
# If you want to route /admin/posts to +PostsController+
# (without the Admin:: module prefix), you could use
@@ -591,7 +591,7 @@ def map_method(method, args, &block)
#
# or, for a single case
#
- # resources :posts, :path => "/admin/posts"
+ # resources :posts, path: "/admin/posts"
#
# In each of these cases, the named routes remain the same as if you did
# not use scope. In the last case, the following paths map to
@@ -609,7 +609,7 @@ module Scoping
#
# Take the following route definition as an example:
#
- # scope :path => ":account_id", :as => "account" do
+ # scope path: ":account_id", as: "account" do
# resources :projects
# end
#
@@ -624,17 +624,17 @@ module Scoping
# === Examples
#
# # route /posts (without the prefix /admin) to <tt>Admin::PostsController</tt>
- # scope :module => "admin" do
+ # scope module: "admin" do
# resources :posts
# end
#
# # prefix the posts resource's requests with '/admin'
- # scope :path => "/admin" do
+ # scope path: "/admin" do
# resources :posts
# end
#
# # prefix the routing helper name: +sekret_posts_path+ instead of +posts_path+
- # scope :as => "sekret" do
+ # scope as: "sekret" do
# resources :posts
# end
def scope(*args)
@@ -680,7 +680,7 @@ def scope(*args)
# Scopes routes to a specific controller
#
# controller "food" do
- # match "bacon", :action => "bacon"
+ # match "bacon", action: "bacon"
# end
def controller(controller, options={})
options[:controller] = controller
@@ -714,17 +714,17 @@ def controller(controller, options={})
# === Examples
#
# # accessible through /sekret/posts rather than /admin/posts
- # namespace :admin, :path => "sekret" do
+ # namespace :admin, path: "sekret" do
# resources :posts
# end
#
# # maps to <tt>Sekret::PostsController</tt> rather than <tt>Admin::PostsController</tt>
- # namespace :admin, :module => "sekret" do
+ # namespace :admin, module: "sekret" do
# resources :posts
# end
#
# # generates +sekret_posts_path+ rather than +admin_posts_path+
- # namespace :admin, :as => "sekret" do
+ # namespace :admin, as: "sekret" do
# resources :posts
# end
def namespace(path, options = {})
@@ -738,7 +738,7 @@ def namespace(path, options = {})
# Allows you to constrain the nested routes based on a set of rules.
# For instance, in order to change the routes to allow for a dot character in the +id+ parameter:
#
- # constraints(:id => /\d+\.\d+/) do
+ # constraints(id: /\d+\.\d+/) do
# resources :posts
# end
#
@@ -748,7 +748,7 @@ def namespace(path, options = {})
# You may use this to also restrict other parameters:
#
# resources :posts do
- # constraints(:post_id => /\d+\.\d+/) do
+ # constraints(post_id: /\d+\.\d+/) do
# resources :comments
# end
# end
@@ -757,7 +757,7 @@ def namespace(path, options = {})
#
# Routes can also be constrained to an IP or a certain range of IP addresses:
#
- # constraints(:ip => /192\.168\.\d+\.\d+/) do
+ # constraints(ip: /192\.168\.\d+\.\d+/) do
# resources :posts
# end
#
@@ -794,8 +794,8 @@ def constraints(constraints = {})
end
# Allows you to set default parameters for a route, such as this:
- # defaults :id => 'home' do
- # match 'scoped_pages/(:id)', :to => 'pages#show'
+ # defaults id: 'home' do
+ # match 'scoped_pages/(:id)', to: 'pages#show'
# end
# Using this, the +:id+ parameter here will default to 'home'.
def defaults(defaults = {})
@@ -902,7 +902,7 @@ def defaults_from_constraints(constraints)
# use dots as part of the +:id+ parameter add a constraint which
# overrides this restriction, e.g:
#
- # resources :articles, :id => /[^\/]+/
+ # resources :articles, id: /[^\/]+/
#
# This allows any character other than a slash as part of your +:id+.
#
@@ -1112,43 +1112,43 @@ def resource(*resources, &block)
# Allows you to change the segment component of the +edit+ and +new+ actions.
# Actions not specified are not changed.
#
- # resources :posts, :path_names => { :new => "brand_new" }
+ # resources :posts, path_names: { new: "brand_new" }
#
# The above example will now change /posts/new to /posts/brand_new
#
# [:path]
# Allows you to change the path prefix for the resource.
#
- # resources :posts, :path => 'postings'
+ # resources :posts, path: 'postings'
#
# The resource and all segments will now route to /postings instead of /posts
#
# [:only]
# Only generate routes for the given actions.
#
- # resources :cows, :only => :show
- # resources :cows, :only => [:show, :index]
+ # resources :cows, only: :show
+ # resources :cows, only: [:show, :index]
#
# [:except]
# Generate all routes except for the given actions.
#
- # resources :cows, :except => :show
- # resources :cows, :except => [:show, :index]
+ # resources :cows, except: :show
+ # resources :cows, except: [:show, :index]
#
# [:shallow]
# Generates shallow routes for nested resource(s). When placed on a parent resource,
# generates shallow routes for all nested resources.
#
- # resources :posts, :shallow => true do
+ # resources :posts, shallow: true do
# resources :comments
# end
#
# Is the same as:
#
# resources :posts do
- # resources :comments, :except => [:show, :edit, :update, :destroy]
+ # resources :comments, except: [:show, :edit, :update, :destroy]
# end
- # resources :comments, :only => [:show, :edit, :update, :destroy]
+ # resources :comments, only: [:show, :edit, :update, :destroy]
#
# This allows URLs for resources that otherwise would be deeply nested such
# as a comment on a blog post like <tt>/posts/a-long-permalink/comments/1234</tt>
@@ -1157,9 +1157,9 @@ def resource(*resources, &block)
# [:shallow_path]
# Prefixes nested shallow routes with the specified path.
#
- # scope :shallow_path => "sekret" do
+ # scope shallow_path: "sekret" do
# resources :posts do
- # resources :comments, :shallow => true
+ # resources :comments, shallow: true
# end
# end
#
@@ -1176,9 +1176,9 @@ def resource(*resources, &block)
# [:shallow_prefix]
# Prefixes nested shallow route names with specified prefix.
#
- # scope :shallow_prefix => "sekret" do
+ # scope shallow_prefix: "sekret" do
# resources :posts do
- # resources :comments, :shallow => true
+ # resources :comments, shallow: true
# end
# end
#
@@ -1199,10 +1199,10 @@ def resource(*resources, &block)
# === Examples
#
# # routes call <tt>Admin::PostsController</tt>
- # resources :posts, :module => "admin"
+ # resources :posts, module: "admin"
#
# # resource actions are at /admin/posts.
- # resources :posts, :path => "admin/posts"
+ # resources :posts, path: "admin/posts"
def resources(*resources, &block)
options = resources.extract_options!.dup
View
6 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -34,7 +34,7 @@ module Routing
# == Prefixed polymorphic helpers
#
# In addition to <tt>polymorphic_url</tt> and <tt>polymorphic_path</tt> methods, a
- # number of prefixed helpers are available as a shorthand to <tt>:action => "..."</tt>
+ # number of prefixed helpers are available as a shorthand to <tt>action: "..."</tt>
# in options. Those are:
#
# * <tt>edit_polymorphic_url</tt>, <tt>edit_polymorphic_path</tt>
@@ -43,7 +43,7 @@ module Routing
# Example usage:
#
# edit_polymorphic_path(@post) # => "/posts/1/edit"
- # polymorphic_path(@post, :format => :pdf) # => "/posts/1.pdf"
+ # polymorphic_path(@post, format: :pdf) # => "/posts/1.pdf"
#
# == Usage with mounted engines
#
@@ -132,7 +132,7 @@ def polymorphic_url(record_or_hash_or_array, options = {})
end
# Returns the path component of a URL for the given record. It uses
- # <tt>polymorphic_url</tt> with <tt>:routing_type => :path</tt>.
+ # <tt>polymorphic_url</tt> with <tt>routing_type: :path</tt>.
def polymorphic_path(record_or_hash_or_array, options = {})
polymorphic_url(record_or_hash_or_array, options.merge(:routing_type => :path))
end
View
8 actionpack/lib/action_dispatch/routing/redirection.rb
@@ -102,7 +102,7 @@ module Redirection
#
# You can also use interpolation in the supplied redirect argument:
#
- # match 'docs/:article', :to => redirect('/wiki/%{article}')
+ # match 'docs/:article', to: redirect('/wiki/%{article}')
#
# Alternatively you can use one of the other syntaxes:
#
@@ -111,7 +111,7 @@ module Redirection
# params, depending of how many arguments your block accepts. A string is required as a
# return value.
#
- # match 'jokes/:number', :to => redirect { |params, request|
+ # match 'jokes/:number', to: redirect { |params, request|
# path = (params[:number].to_i.even? ? "wheres-the-beef" : "i-love-lamp")
# "http://#{request.host_with_port}/#{path}"
# }
@@ -122,8 +122,8 @@ module Redirection
# The options version of redirect allows you to supply only the parts of the url which need
# to change, it also supports interpolation of the path similar to the first example.
#
- # match 'stores/:name', :to => redirect(:subdomain => 'stores', :path => '/%{name}')
- # match 'stores/:name(*all)', :to => redirect(:subdomain => 'stores', :path => '/%{name}%{all}')
+ # match 'stores/:name', to: redirect(subdomain: 'stores', path: '/%{name}')
+ # match 'stores/:name(*all)', to: redirect(subdomain: 'stores', path: '/%{name}%{all}')
#
# Finally, an object which responds to call can be supplied to redirect, allowing you to reuse
# common redirect routes. The call method must accept two arguments, params and request, and return
View
12 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -176,11 +176,11 @@ def define_named_route_methods(name, route)
#
# Instead of:
#
- # foo_url(:bar => bar, :baz => baz, :bang => bang)
+ # foo_url(bar: bar, baz: baz, bang: bang)
#
# Also allow options hash, so you can do:
#
- # foo_url(bar, baz, bang, :sort_by => 'baz')
+ # foo_url(bar, baz, bang, sort_by: 'baz')
#
def define_url_helper(route, name, options)
@module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
@@ -471,7 +471,7 @@ def normalize_options!
# If an explicit :controller was given, always make :action explicit
# too, so that action expiry works as expected for things like
#
- # generate({:controller => 'content'}, {:controller => 'content', :action => 'show'})
+ # generate({controller: 'content'}, {controller: 'content', action: 'show'})
#
# (the above is from the unit tests). In the above case, because the
# controller was explicitly given, but no action, the action is implied to
@@ -500,7 +500,7 @@ def normalize_controller_action_id!
use_recall_for(:id)
end
- # if the current controller is "foo/bar/baz" and :controller => "baz/bat"
+ # if the current controller is "foo/bar/baz" and controller: "baz/bat"
# is specified, the controller becomes "foo/baz/bat"
def use_relative_controller!
if !named_route && different_controller? && !controller.start_with?("/")
@@ -516,8 +516,8 @@ def normalize_controller!
@options[:controller] = controller.sub(%r{^/}, '') if controller
end
- # This handles the case of :action => nil being explicitly passed.
- # It is identical to :action => "index"
+ # This handles the case of action: nil being explicitly passed.
+ # It is identical to action: "index"
def handle_nil_action!
if options.has_key?(:action) && options[:action].nil?
options[:action] = 'index'
View
30 actionpack/lib/action_dispatch/routing/url_for.rb
@@ -18,8 +18,8 @@ module Routing
# of parameters. For example, you've probably had the chance to write code
# like this in one of your views:
#
- # <%= link_to('Click here', :controller => 'users',
- # :action => 'new', :message => 'Welcome!') %>
+ # <%= link_to('Click here', controller: 'users',
+ # action: 'new', message: 'Welcome!') %>
# # => "/users/new?message=Welcome%21"
#
# link_to, and all other functions that require URL generation functionality,
@@ -28,22 +28,22 @@ module Routing
# the same path as the above example by using the following code:
#
# include UrlFor
- # url_for(:controller => 'users',
- # :action => 'new',
- # :message => 'Welcome!',
- # :only_path => true)
+ # url_for(controller: 'users',
+ # action: 'new',
+ # message: 'Welcome!',
+ # only_path: true)
# # => "/users/new?message=Welcome%21"
#
- # Notice the <tt>:only_path => true</tt> part. This is because UrlFor has no
+ # Notice the <tt>only_path: true</tt> part. This is because UrlFor has no
# information about the website hostname that your Rails app is serving. So if you
# want to include the hostname as well, then you must also pass the <tt>:host</tt>
# argument:
#
# include UrlFor
- # url_for(:controller => 'users',
- # :action => 'new',
- # :message => 'Welcome!',
- # :host => 'www.example.com')
+ # url_for(controller: 'users',
+ # action: 'new',
+ # message: 'Welcome!',
+ # host: 'www.example.com')
# # => "http://www.example.com/users/new?message=Welcome%21"
#
# By default, all controllers and views have access to a special version of url_for,
@@ -134,13 +134,13 @@ def url_options
# Any other key (<tt>:controller</tt>, <tt>:action</tt>, etc.) given to
# +url_for+ is forwarded to the Routes module.
#
- # url_for :controller => 'tasks', :action => 'testing', :host => 'somehost.org', :port => '8080'
+ # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', port: '8080'
# # => 'http://somehost.org:8080/tasks/testing'
- # url_for :controller => 'tasks', :action => 'testing', :host => 'somehost.org', :anchor => 'ok', :only_path => true
+ # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', anchor: 'ok', only_path: true
# # => '/tasks/testing#ok'
- # url_for :controller => 'tasks', :action => 'testing', :trailing_slash => true
+ # url_for controller: 'tasks', action: 'testing', trailing_slash: true
# # => 'http://somehost.org/tasks/testing/'
- # url_for :controller => 'tasks', :action => 'testing', :host => 'somehost.org', :number => '33'
+ # url_for controller: 'tasks', action: 'testing', host: 'somehost.org', number: '33'
# # => 'http://somehost.org/tasks/testing?number=33'
def url_for(options = nil)
case options
View
6 actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -35,11 +35,11 @@ def assert_response(type, message = nil)
end
# Assert that the redirection options passed in match those of the redirect called in the latest action.
- # This match can be partial, such that <tt>assert_redirected_to(:controller => "weblog")</tt> will also
- # match the redirection of <tt>redirect_to(:controller => "weblog", :action => "show")</tt> and so on.
+ # This match can be partial, such that <tt>assert_redirected_to(controller: "weblog")</tt> will also
+ # match the redirection of <tt>redirect_to(controller: "weblog", action: "show")</tt> and so on.
#
# # assert that the redirection was to the "index" action on the WeblogController
- # assert_redirected_to :controller => "weblog", :action => "index"
+ # assert_redirected_to controller: "weblog", action: "index"
#
# # assert that the redirection was to the named route login_url
# assert_redirected_to login_url
View
30 actionpack/lib/action_dispatch/testing/assertions/routing.rb
@@ -15,28 +15,28 @@ module RoutingAssertions
# and a :method containing the required HTTP verb.
#
# # assert that POSTing to /items will call the create action on ItemsController
- # assert_recognizes({:controller => 'items', :action => 'create'}, {:path => 'items', :method => :post})
+ # assert_recognizes({controller: 'items', action: 'create'}, {path: 'items', method: :post})
#
# You can also pass in +extras+ with a hash containing URL parameters that would normally be in the query string. This can be used
# to assert that values in the query string string will end up in the params hash correctly. To test query strings you must use the
# extras argument, appending the query string on the path directly will not work. For example:
#
# # assert that a path of '/items/list/1?view=print' returns the correct options
- # assert_recognizes({:controller => 'items', :action => 'list', :id => '1', :view => 'print'}, 'items/list/1', { :view => "print" })
+ # assert_recognizes({controller: 'items', action: 'list', id: '1', view: 'print'}, 'items/list/1', { view: "print" })
#
# The +message+ parameter allows you to pass in an error message that is displayed upon failure.
#
# # Check the default route (i.e., the index action)
- # assert_recognizes({:controller => 'items', :action => 'index'}, 'items')
+ # assert_recognizes({controller: 'items', action: 'index'}, 'items')
#
# # Test a specific action
- # assert_recognizes({:controller => 'items', :action => 'list'}, 'items/list')
+ # assert_recognizes({controller: 'items', action: 'list'}, 'items/list')
#
# # Test an action with a parameter
- # assert_recognizes({:controller => 'items', :action => 'destroy', :id => '1'}, 'items/destroy/1')
+ # assert_recognizes({controller: 'items', action: 'destroy', id: '1'}, 'items/destroy/1')
#
# # Test a custom route
- # assert_recognizes({:controller => 'items', :action => 'show', :id => '1'}, 'view/item1')
+ # assert_recognizes({controller: 'items', action: 'show', id: '1'}, 'view/item1')
def assert_recognizes(expected_options, path, extras={}, message=nil)
request = recognized_request_for(path, extras)
@@ -57,16 +57,16 @@ def assert_recognizes(expected_options, path, extras={}, message=nil)
# The +defaults+ parameter is unused.
#
# # Asserts that the default action is generated for a route with no action
- # assert_generates "/items", :controller => "items", :action => "index"
+ # assert_generates "/items", controller: "items", action: "index"
#
# # Tests that the list action is properly routed
- # assert_generates "/items/list", :controller => "items", :action => "list"
+ # assert_generates "/items/list", controller: "items", action: "list"
#
# # Tests the generation of a route with a parameter
- # assert_generates "/items/list/1", { :controller => "items", :action => "list", :id => "1" }
+ # assert_generates "/items/list/1", { controller: "items", action: "list", id: "1" }
#
# # Asserts that the generated route gives us our custom route
- # assert_generates "changesets/12", { :controller => 'scm', :action => 'show_diff', :revision => "12" }
+ # assert_generates "changesets/12", { controller: 'scm', action: 'show_diff', revision: "12" }
def assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)
if expected_path =~ %r{://}
fail_on(URI::InvalidURIError) do
@@ -97,19 +97,19 @@ def assert_generates(expected_path, options, defaults={}, extras = {}, message=n
# +message+ parameter allows you to specify a custom error message to display upon failure.
#
# # Assert a basic route: a controller with the default action (index)
- # assert_routing '/home', :controller => 'home', :action => 'index'
+ # assert_routing '/home', controller: 'home', action: 'index'
#
# # Test a route generated with a specific controller, action, and parameter (id)
- # assert_routing '/entries/show/23', :controller => 'entries', :action => 'show', :id => 23
+ # assert_routing '/entries/show/23', controller: 'entries', action: 'show', id: 23
#
# # Assert a basic route (controller + default action), with an error message if it fails
- # assert_routing '/store', { :controller => 'store', :action => 'index' }, {}, {}, 'Route for store index not generated properly'
+ # assert_routing '/store', { controller: 'store', action: 'index' }, {}, {}, 'Route for store index not generated properly'
#
# # Tests a route, providing a defaults hash
- # assert_routing 'controller/action/9', {:id => "9", :item => "square"}, {:controller => "controller", :action => "action"}, {}, {:item => "square"}
+ # assert_routing 'controller/action/9', {id: "9", item: "square"}, {controller: "controller", action: "action"}, {}, {item: "square"}
#
# # Tests a route with a HTTP method
- # assert_routing({ :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" })
+ # assert_routing({ method: 'put', path: '/product/321' }, { controller: "product", action: "update", id: "321" })
def assert_routing(path, options, defaults={}, extras={}, message=nil)
assert_recognizes(options, path, extras, message)
View
2  actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -167,7 +167,7 @@ def css_select(*args)
# assert_select "title", "Welcome"
#
# # Page title is "Welcome" and there is only one title element
- # assert_select "title", {:count => 1, :text => "Welcome"},
+ # assert_select "title", {count: 1, text: "Welcome"},
# "Wrong title or more than one title element"
#
# # Page contains no forms
View
38 actionpack/lib/action_dispatch/testing/assertions/tag.rb
@@ -49,44 +49,44 @@ module TagAssertions
# * if the condition is +false+ or +nil+, the value must be +nil+.
#
# # Assert that there is a "span" tag
- # assert_tag :tag => "span"
+ # assert_tag tag: "span"
#
# # Assert that there is a "span" tag with id="x"
- # assert_tag :tag => "span", :attributes => { :id => "x" }
+ # assert_tag tag: "span", attributes: { id: "x" }
#
# # Assert that there is a "span" tag using the short-hand
# assert_tag :span
#
# # Assert that there is a "span" tag with id="x" using the short-hand
- # assert_tag :span, :attributes => { :id => "x" }
+ # assert_tag :span, attributes: { id: "x" }
#
# # Assert that there is a "span" inside of a "div"
- # assert_tag :tag => "span", :parent => { :tag => "div" }
+ # assert_tag tag: "span", parent: { tag: "div" }
#
# # Assert that there is a "span" somewhere inside a table
- # assert_tag :tag => "span", :ancestor => { :tag => "table" }
+ # assert_tag tag: "span", ancestor: { tag: "table" }
#
# # Assert that there is a "span" with at least one "em" child
- # assert_tag :tag => "span", :child => { :tag => "em" }
+ # assert_tag tag: "span", child: { tag: "em" }
#
# # Assert that there is a "span" containing a (possibly nested)
# # "strong" tag.
- # assert_tag :tag => "span", :descendant => { :tag => "strong" }
+ # assert_tag tag: "span", descendant: { tag: "strong" }
#
# # Assert that there is a "span" containing between 2 and 4 "em" tags
# # as immediate children
- # assert_tag :tag => "span",
- # :children => { :count => 2..4, :only => { :tag => "em" } }
+ # assert_tag tag: "span",
+ # children: { count: 2..4, only: { tag: "em" } }
#
# # Get funky: assert that there is a "div", with an "ul" ancestor
# # and an "li" parent (with "class" = "enum"), and containing a
# # "span" descendant that contains text matching /hello world/
- # assert_tag :tag => "div",
- # :ancestor => { :tag => "ul" },
- # :parent => { :tag => "li",
- # :attributes => { :class => "enum" } },
- # :descendant => { :tag => "span",
- # :child => /hello world/ }
+ # assert_tag tag: "div",
+ # ancestor: { tag: "ul" },
+ # parent: { tag: "li",
+ # attributes: { class: "enum" } },
+ # descendant: { tag: "span",
+ # child: /hello world/ }
#
# <b>Please note</b>: +assert_tag+ and +assert_no_tag+ only work
# with well-formed XHTML. They recognize a few tags as implicitly self-closing
@@ -103,15 +103,15 @@ def assert_tag(*opts)
# exist. (See +assert_tag+ for a full discussion of the syntax.)
#
# # Assert that there is not a "div" containing a "p"
- # assert_no_tag :tag => "div", :descendant => { :tag => "p" }
+ # assert_no_tag tag: "div", descendant: { tag: "p" }
#
# # Assert that an unordered list is empty
- # assert_no_tag :tag => "ul", :descendant => { :tag => "li" }
+ # assert_no_tag tag: "ul", descendant: { tag: "li" }
#
# # Assert that there is not a "p" tag with between 1 to 3 "img" tags
# # as immediate children
- # assert_no_tag :tag => "p",
- # :children => { :count => 1..3, :only => { :tag => "img" } }
+ # assert_no_tag tag: "p",
+ # children: { count: 1..3, only: { tag: "img" } }
def assert_no_tag(*opts)
opts = opts.size > 1 ? opts.last.merge({ :tag => opts.first.to_s }) : opts.first
tag = find_tag(opts)
View
12 actionpack/lib/action_dispatch/testing/integration.rb
@@ -430,8 +430,8 @@ def integration_session
# assert_equal 200, status
#
# # post the login and follow through to the home page
- # post "/login", :username => people(:jamis).username,
- # :password => people(:jamis).password
+ # post "/login", username: people(:jamis).username,
+ # password: people(:jamis).password
# follow_redirect!
# assert_equal 200, status
# assert_equal "/home", path
@@ -464,13 +464,13 @@ def integration_session
# module CustomAssertions
# def enter(room)
# # reference a named route, for maximum internal consistency!
- # get(room_url(:id => room.id))
+ # get(room_url(id: room.id))
# assert(...)
# ...
# end
#
# def speak(room, message)
- # xml_http_request "/say/#{room.id}", :message => message
+ # xml_http_request "/say/#{room.id}", message: message
# assert(...)
# ...
# end
@@ -480,8 +480,8 @@ def integration_session
# open_session do |sess|
# sess.extend(CustomAssertions)
# who = people(who)
- # sess.post "/login", :username => who.username,
- # :password => who.password
+ # sess.post "/login", username: who.username,
+ # password: who.password
# assert(...)
# end
# end
View
4 actionpack/lib/action_dispatch/testing/test_process.rb
@@ -28,12 +28,12 @@ def redirect_to_url
# Shortcut for <tt>Rack::Test::UploadedFile.new(ActionController::TestCase.fixture_path + path, type)</tt>:
#
- # post :change_avatar, :avatar => fixture_file_upload('/files/spongebob.png', 'image/png')
+ # post :change_avatar, avatar: fixture_file_upload('/files/spongebob.png', 'image/png')
#
# To upload binary files on Windows, pass <tt>:binary</tt> as the last parameter.
# This will not affect other platforms:
#
- # post :change_avatar, :avatar => fixture_file_upload('/files/spongebob.png', 'image/png', :binary)
+ # post :change_avatar, avatar: fixture_file_upload('/files/spongebob.png', 'image/png', :binary)
def fixture_file_upload(path, mime_type = nil, binary = false)
fixture_path = self.class.fixture_path if self.class.respond_to?(:fixture_path)
Rack::Test::UploadedFile.new("#{fixture_path}#{path}", mime_type, binary)
View
2  actionpack/lib/action_view/base.rb
@@ -55,7 +55,7 @@ module ActionView #:nodoc:
#
# You can pass local variables to sub templates by using a hash with the variable names as keys and the objects as values:
#
- # <%= render "shared/header", { :headline => "Welcome", :person => person } %>
+ # <%= render "shared/header", { headline: "Welcome", person: person } %>
#
# These can now be accessed in <tt>shared/header</tt> with:
#
View
64 actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -24,7 +24,7 @@ module AssetTagHelper
# Returns an HTML script tag for each of the +sources+ provided.
#
# Sources may be paths to JavaScript files. Relative paths are assumed to be relative
- # to <tt>public/javascripts</tt>, full paths are assumed to be relative to the document
+ # to <tt>assets/javascripts</tt>, full paths are assumed to be relative to the document
# root. Relative paths are idiomatic, use absolute paths only when needed.
#
# When passing paths, the ".js" extension is optional.
@@ -33,13 +33,13 @@ module AssetTagHelper
# last argument.
#
# javascript_include_tag "xmlhr"
- # # => <script src="/javascripts/xmlhr.js?1284139606"></script>
+ # # => <script src="/assets/xmlhr.js?1284139606"></script>
#
# javascript_include_tag "xmlhr.js"
- # # => <script src="/javascripts/xmlhr.js?1284139606"></script>
+ # # => <script src="/assets/xmlhr.js?1284139606"></script>
#
# javascript_include_tag "common.javascript", "/elsewhere/cools"
- # # => <script src="/javascripts/common.javascript?1284139606"></script>
+ # # => <script src="/assets/common.javascript?1284139606"></script>
# # <script src="/elsewhere/cools.js?1423139606"></script>
#
# javascript_include_tag "http://www.example.com/xmlhr"
@@ -65,24 +65,24 @@ def javascript_include_tag(*sources)
# to "screen", so you must explicitely set it to "all" for the stylesheet(s) to
# apply to all media types.
#
- # stylesheet_link_tag "style" # =>
- # <link href="/stylesheets/style.css" media="screen" rel="stylesheet" />
+ # stylesheet_link_tag "style"
+ # # => <link href="/assets/style.css" media="screen" rel="stylesheet" />
#
- # stylesheet_link_tag "style.css" # =>
- # <link href="/stylesheets/style.css" media="screen" rel="stylesheet" />
+ # stylesheet_link_tag "style.css"
+ # # => <link href="/assets/style.css" media="screen" rel="stylesheet" />
#
- # stylesheet_link_tag "http://www.example.com/style.css" # =>
- # <link href="http://www.example.com/style.css" media="screen" rel="stylesheet" />
+ # stylesheet_link_tag "http://www.example.com/style.css"
+ # # => <link href="http://www.example.com/style.css" media="screen" rel="stylesheet" />
#
- # stylesheet_link_tag "style", :media => "all" # =>
- # <link href="/stylesheets/style.css" media="all" rel="stylesheet" />
+ # stylesheet_link_tag "style", media: "all"
+ # # => <link href="/assets/style.css" media="all" rel="stylesheet" />
#
- # stylesheet_link_tag "style", :media => "print" # =>
- # <link href="/stylesheets/style.css" media="print" rel="stylesheet" />
+ # stylesheet_link_tag "style", media: "print"
+ # # => <link href="/assets/style.css" media="print" rel="stylesheet" />
#
- # stylesheet_link_tag "random.styles", "/css/stylish" # =>
- # <link href="/stylesheets/random.styles" media="screen" rel="stylesheet" />
- # <link href="/css/stylish.css" media="screen" rel="stylesheet" />
+ # stylesheet_link_tag "random.styles", "/css/stylish"
+ # # => <link href="/assets/random.styles" media="screen" rel="stylesheet" />
+ # # <link href="/css/stylish.css" media="screen" rel="stylesheet" />
#
def stylesheet_link_tag(*sources)
options = sources.extract_options!.stringify_keys
@@ -111,13 +111,13 @@ def stylesheet_link_tag(*sources)
# # => <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.currenthost.com/controller/action" />
# auto_discovery_link_tag(:atom)
# # => <link rel="alternate" type="application/atom+xml" title="ATOM" href="http://www.currenthost.com/controller/action" />
- # auto_discovery_link_tag(:rss, {:action => "feed"})
+ # auto_discovery_link_tag(:rss, {action: "feed"})
# # => <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.currenthost.com/controller/feed" />
- # auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"})
+ # auto_discovery_link_tag(:rss, {action: "feed"}, {title: "My RSS"})
# # => <link rel="alternate" type="application/rss+xml" title="My RSS" href="http://www.currenthost.com/controller/feed" />
- # auto_discovery_link_tag(:rss, {:controller => "news", :action => "feed"})
+ # auto_discovery_link_tag(:rss, {controller: "news", action: "feed"})
# # => <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.currenthost.com/news/feed" />
- # auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", {:title => "Example RSS"})
+ # auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", {title: "Example RSS"})
# # => <link rel="alternate" type="application/rss+xml" title="Example RSS" href="http://www.example.com/feed" />
def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
if !(type == :rss || type == :atom) && tag_options[:type].blank?
@@ -157,7 +157,7 @@ def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
# will be used if you add the page to the home screen of an iPod Touch, iPhone, or iPad.
# The following call would generate such a tag:
#
- # <%= favicon_link_tag 'mb-icon.png', :rel => 'apple-touch-icon', :type => 'image/png' %>
+ # <%= favicon_link_tag 'mb-icon.png', rel: 'apple-touch-icon', type: 'image/png' %>
def favicon_link_tag(source='favicon.ico', options={})
tag('link', {
:rel => 'shortcut icon',
@@ -183,13 +183,13 @@ def favicon_link_tag(source='favicon.ico', options={})
# # => <img alt="Icon" src="/assets/icon" />
# image_tag("icon.png")
# # => <img alt="Icon" src="/assets/icon.png" />
- # image_tag("icon.png", :size => "16x10", :alt => "Edit Entry")
+ # image_tag("icon.png", size: "16x10", alt: "Edit Entry")
# # => <img src="/assets/icon.png" width="16" height="10" alt="Edit Entry" />
- # image_tag("/icons/icon.gif", :size => "16")
+ # image_tag("/icons/icon.gif", size: "16")
# # => <img src="/icons/icon.gif" width="16" height="16" alt="Icon" />
- # image_tag("/icons/icon.gif", :height => '32', :width => '32')
+ # image_tag("/icons/icon.gif", height: '32', width: '32')
# # => <img alt="Icon" height="32" src="/icons/icon.gif" width="32" />
- # image_tag("/icons/icon.gif", :class => "menu_icon")
+ # image_tag("/icons/icon.gif", class: "menu_icon")
# # => <img alt="Icon" class="menu_icon" src="/icons/icon.gif" />
def image_tag(source, options={})
options = options.symbolize_keys
@@ -232,19 +232,19 @@ def image_alt(src)
# # => <video src="/videos/trailer" />
# video_tag("trailer.ogg")
# # => <video src="/videos/trailer.ogg" />
- # video_tag("trailer.ogg", :controls => true, :autobuffer => true)
+ # video_tag("trailer.ogg", controls: true, autobuffer: true)
# # => <video autobuffer="autobuffer" controls="controls" src="/videos/trailer.ogg" />
- # video_tag("trailer.m4v", :size => "16x10", :poster => "screenshot.png")
+ # video_tag("trailer.m4v", size: "16x10", poster: "screenshot.png")
# # => <video src="/videos/trailer.m4v" width="16" height="10" poster="/assets/screenshot.png" />
- # video_tag("/trailers/hd.avi", :size => "16x16")
+ # video_tag("/trailers/hd.avi", size: "16x16")
# # => <video src="/trailers/hd.avi" width="16" height="16" />
- # video_tag("/trailers/hd.avi", :height => '32', :width => '32')
+ # video_tag("/trailers/hd.avi", height: '32', width: '32')
# # => <video height="32" src="/trailers/hd.avi" width="32" />
# video_tag("trailer.ogg", "trailer.flv")
# # => <video><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
# video_tag(["trailer.ogg", "trailer.flv"])
# # => <video><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
- # video_tag(["trailer.ogg", "trailer.flv"], :size => "160x120")
+ # video_tag(["trailer.ogg", "trailer.flv"], size: "160x120")
# # => <video height="120" width="160"><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
def video_tag(*sources)
multiple_sources_tag('video', sources) do |options|
@@ -264,7 +264,7 @@ def video_tag(*sources)
# <audio src="/audios/sound" />
# audio_tag("sound.wav") # =>
# <audio src="/audios/sound.wav" />
- # audio_tag("sound.wav", :autoplay => true, :controls => true) # =>
+ # audio_tag("sound.wav", autoplay: true, controls: true) # =>
# <audio autoplay="autoplay" controls="controls" src="/audios/sound.wav" />
# audio_tag("sound.wav", "sound.mid") # =>
# <audio><source src="/audios/sound.wav" /><source src="/audios/sound.mid" /></audio>
View
12 actionpack/lib/action_view/helpers/atom_feed_helper.rb
@@ -12,7 +12,7 @@ module AtomFeedHelper
# config/routes.rb:
# Basecamp::Application.routes.draw do
# resources :posts
- # root :to => "posts#index"
+ # root to: "posts#index"
# end
#
# app/controllers/posts_controller.rb:
@@ -37,7 +37,7 @@ module AtomFeedHelper
# @posts.each do |post|
# feed.entry(post) do |entry|
# entry.title(post.title)
- # entry.content(post.body, :type => 'html')
+ # entry.content(post.body, type: 'html')
#
# entry.author do |author|
# author.name("DHH")
@@ -69,7 +69,7 @@ module AtomFeedHelper
# @posts.each do |post|
# feed.entry(post) do |entry|
# entry.title(post.title)
- # entry.content(post.body, :type => 'html')
+ # entry.content(post.body, type: 'html')
# entry.tag!('app:edited', Time.now)
#
# entry.author do |author|
@@ -80,11 +80,11 @@ module AtomFeedHelper
# end
#
# The Atom spec defines five elements (content rights title subtitle
- # summary) which may directly contain xhtml content if :type => 'xhtml'
+ # summary) which may directly contain xhtml content if type: 'xhtml'
# is specified as an attribute. If so, this helper will take care of
# the enclosing div and xhtml namespace declaration. Example usage:
#
- # entry.summary :type => 'xhtml' do |xhtml|
+ # entry.summary type: 'xhtml' do |xhtml|
# xhtml.p pluralize(order.line_items.count, "line item")
# xhtml.p "Shipped to #{order.address}"
# xhtml.p "Paid by #{order.pay_type}"
@@ -149,7 +149,7 @@ def method_missing(method, *arguments, &block)
# True if the method name matches one of the five elements defined
# in the Atom spec as potentially containing XHTML content and
- # if :type => 'xhtml' is, in fact, specified.
+ # if type: 'xhtml' is, in fact, specified.
def xhtml_block?(method, arguments)
if XHTML_TAG_NAMES.include?(method.to_s)
last = arguments.last
View
10 actionpack/lib/action_view/helpers/capture_helper.rb
@@ -99,7 +99,7 @@ def capture(*args)
#
# Then, in another view, you could to do something like this:
#
- # <%= link_to 'Logout', :action => 'logout', :remote => true %>
+ # <%= link_to 'Logout', action: 'logout', remote: true %>
#
# <% content_for :script do %>
# <%= javascript_include_tag :defaults %>
@@ -112,13 +112,13 @@ def capture(*args)
# identifier in order. For example:
#
# <% content_for :navigation do %>
- # <li><%= link_to 'Home', :action => 'index' %></li>
+ # <li><%= link_to 'Home', action: 'index' %></li>
# <% end %>
#
# <%# Add some other content, or use a different template: %>
#
# <% content_for :navigation do %>
- # <li><%= link_to 'Login', :action => 'login' %></li>
+ # <li><%= link_to 'Login', action: 'login' %></li>
# <% end %>
#
# Then, in another template or layout, this code would render both links in order: