aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_controller/metal.rb4
-rw-r--r--actionpack/lib/action_controller/metal/conditional_get.rb2
-rw-r--r--actionpack/lib/action_controller/metal/data_streaming.rb10
-rw-r--r--actionpack/lib/action_controller/metal/force_ssl.rb2
-rw-r--r--actionpack/lib/action_controller/metal/head.rb4
-rw-r--r--actionpack/lib/action_controller/metal/http_authentication.rb20
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb26
-rw-r--r--actionpack/lib/action_controller/metal/params_wrapper.rb4
-rw-r--r--actionpack/lib/action_controller/metal/redirecting.rb22
-rw-r--r--actionpack/lib/action_controller/metal/renderers.rb6
-rw-r--r--actionpack/lib/action_controller/metal/request_forgery_protection.rb6
-rw-r--r--actionpack/lib/action_controller/metal/responder.rb20
-rw-r--r--actionpack/lib/action_controller/metal/streaming.rb6
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb2
-rw-r--r--actionpack/lib/action_controller/metal/url_for.rb2
-rw-r--r--actionpack/lib/action_controller/test_case.rb22
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb4
-rw-r--r--actionpack/lib/action_dispatch/middleware/cookies.rb14
-rw-r--r--actionpack/lib/action_dispatch/middleware/session/cookie_store.rb4
-rw-r--r--actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb4
-rw-r--r--actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb2
-rw-r--r--actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb4
-rw-r--r--actionpack/lib/action_dispatch/routing.rb48
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb110
-rw-r--r--actionpack/lib/action_dispatch/routing/polymorphic_routes.rb6
-rw-r--r--actionpack/lib/action_dispatch/routing/redirection.rb8
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb12
-rw-r--r--actionpack/lib/action_dispatch/routing/url_for.rb30
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/response.rb6
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/routing.rb30
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/selector.rb2
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/tag.rb38
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb12
-rw-r--r--actionpack/lib/action_dispatch/testing/test_process.rb4
-rw-r--r--actionpack/lib/action_view/base.rb2
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb64
-rw-r--r--actionpack/lib/action_view/helpers/atom_feed_helper.rb12
-rw-r--r--actionpack/lib/action_view/helpers/capture_helper.rb10
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb188
-rw-r--r--actionpack/lib/action_view/helpers/debug_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb44
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb108
-rw-r--r--actionpack/lib/action_view/helpers/javascript_helper.rb8
-rw-r--r--actionpack/lib/action_view/helpers/number_helper.rb112
-rw-r--r--actionpack/lib/action_view/helpers/record_tag_helper.rb6
-rw-r--r--actionpack/lib/action_view/helpers/rendering_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/sanitize_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb14
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb44
-rw-r--r--actionpack/lib/action_view/helpers/translation_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb8
-rw-r--r--actionpack/lib/action_view/renderer/partial_renderer.rb54
-rw-r--r--actionpack/lib/action_view/routing_url_for.rb14
-rw-r--r--actionpack/lib/action_view/vendor/html-scanner/html/node.rb24
-rw-r--r--activemodel/lib/active_model/errors.rb32
-rw-r--r--activemodel/lib/active_model/validations.rb10
-rw-r--r--activemodel/lib/active_model/validations/acceptance.rb5
-rw-r--r--activemodel/lib/active_model/validations/confirmation.rb3
-rw-r--r--activemodel/lib/active_model/validations/exclusion.rb3
-rw-r--r--activemodel/lib/active_model/validations/format.rb3
-rw-r--r--activemodel/lib/active_model/validations/inclusion.rb3
-rw-r--r--activemodel/lib/active_model/validations/numericality.rb3
-rw-r--r--activemodel/lib/active_model/validations/presence.rb1
-rw-r--r--activemodel/lib/active_model/validations/validates.rb11
-rw-r--r--activemodel/lib/active_model/validations/with.rb2
-rw-r--r--activemodel/lib/active_model/validator.rb2
-rw-r--r--activemodel/test/cases/validations/i18n_generate_message_validation_test.rb24
-rw-r--r--activemodel/test/cases/validations/validates_test.rb2
-rw-r--r--activerecord/lib/active_record/associations/association.rb2
-rw-r--r--activerecord/lib/active_record/associations/preloader.rb6
-rw-r--r--activerecord/lib/active_record/associations/singular_association.rb2
-rw-r--r--activerecord/lib/active_record/associations/through_association.rb2
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb25
-rw-r--r--activerecord/lib/active_record/attribute_methods/before_type_cast.rb43
-rw-r--r--activerecord/lib/active_record/callbacks.rb14
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb42
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb48
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb2
-rw-r--r--activerecord/lib/active_record/errors.rb11
-rw-r--r--activerecord/lib/active_record/fixtures.rb1
-rw-r--r--activerecord/lib/active_record/nested_attributes.rb6
-rw-r--r--activerecord/lib/active_record/persistence.rb18
-rw-r--r--activerecord/lib/active_record/reflection.rb24
-rw-r--r--activerecord/lib/active_record/relation.rb10
-rw-r--r--activesupport/lib/active_support/core_ext/array/wrap.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/hash/deep_merge.rb6
-rw-r--r--activesupport/lib/active_support/core_ext/hash/slice.rb6
-rw-r--r--activesupport/lib/active_support/core_ext/string/inflections.rb4
-rw-r--r--guides/source/3_1_release_notes.md4
-rw-r--r--guides/source/action_controller_overview.md2
-rw-r--r--guides/source/active_record_querying.md4
-rw-r--r--guides/source/active_record_validations_callbacks.md4
-rw-r--r--guides/source/active_support_core_extensions.md36
-rw-r--r--guides/source/active_support_instrumentation.md4
-rw-r--r--guides/source/asset_pipeline.md3
-rw-r--r--guides/source/configuring.md2
-rw-r--r--guides/source/contributing_to_ruby_on_rails.md1
-rw-r--r--guides/source/i18n.md2
-rw-r--r--guides/source/layouts_and_rendering.md6
-rw-r--r--guides/source/migrations.md5
-rw-r--r--guides/source/upgrading_ruby_on_rails.md4
-rw-r--r--guides/source/working_with_javascript_in_rails.md1
105 files changed, 873 insertions, 809 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb
index f5ab1e2350..832dec7b2a 100644
--- a/actionpack/lib/action_controller/metal.rb
+++ b/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 @@ module ActionController
# 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.
diff --git a/actionpack/lib/action_controller/metal/conditional_get.rb b/actionpack/lib/action_controller/metal/conditional_get.rb
index 3f37a6a618..426adfe675 100644
--- a/actionpack/lib/action_controller/metal/conditional_get.rb
+++ b/actionpack/lib/action_controller/metal/conditional_get.rb
@@ -64,7 +64,7 @@ module ActionController
#
# 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
diff --git a/actionpack/lib/action_controller/metal/data_streaming.rb b/actionpack/lib/action_controller/metal/data_streaming.rb
index 5422cb93c4..334943818c 100644
--- a/actionpack/lib/action_controller/metal/data_streaming.rb
+++ b/actionpack/lib/action_controller/metal/data_streaming.rb
@@ -47,11 +47,11 @@ module ActionController #:nodoc:
#
# 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 @@ module ActionController #:nodoc:
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 @@ module ActionController #:nodoc:
#
# 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:
diff --git a/actionpack/lib/action_controller/metal/force_ssl.rb b/actionpack/lib/action_controller/metal/force_ssl.rb
index e905a3cf1d..c38d8ccef3 100644
--- a/actionpack/lib/action_controller/metal/force_ssl.rb
+++ b/actionpack/lib/action_controller/metal/force_ssl.rb
@@ -22,7 +22,7 @@ module ActionController
# an +:if+ or +:unless+ condition.
#
# class AccountsController < ApplicationController
- # force_ssl :if => :ssl_configured?
+ # force_ssl if: :ssl_configured?
#
# def ssl_configured?
# !Rails.env.development?
diff --git a/actionpack/lib/action_controller/metal/head.rb b/actionpack/lib/action_controller/metal/head.rb
index 747e1273be..bbace49fd9 100644
--- a/actionpack/lib/action_controller/metal/head.rb
+++ b/actionpack/lib/action_controller/metal/head.rb
@@ -7,9 +7,9 @@ module ActionController
# 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:
#
diff --git a/actionpack/lib/action_controller/metal/http_authentication.rb b/actionpack/lib/action_controller/metal/http_authentication.rb
index 03b8d8db1a..6d46586367 100644
--- a/actionpack/lib/action_controller/metal/http_authentication.rb
+++ b/actionpack/lib/action_controller/metal/http_authentication.rb
@@ -8,14 +8,14 @@ module ActionController
# === 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 @@ module ActionController
# 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 @@ module ActionController
# 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 @@ module ActionController
# 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.
#
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index d86e8092c4..6bf306ac5b 100644
--- a/actionpack/lib/action_controller/metal/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
@@ -23,13 +23,13 @@ module ActionController #:nodoc:
# <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 @@ module ActionController #:nodoc:
#
# respond_to do |format|
# format.html
- # format.xml { render :xml => @people }
+ # format.xml { render xml: @people }
# end
# end
#
@@ -98,7 +98,7 @@ module ActionController #:nodoc:
# 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 @@ module ActionController #:nodoc:
#
# 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 @@ module ActionController #:nodoc:
# 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 @@ module ActionController #:nodoc:
# * 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 @@ module ActionController #:nodoc:
# 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 @@ module ActionController #: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
diff --git a/actionpack/lib/action_controller/metal/params_wrapper.rb b/actionpack/lib/action_controller/metal/params_wrapper.rb
index 88b9e78da7..09abc999c1 100644
--- a/actionpack/lib/action_controller/metal/params_wrapper.rb
+++ b/actionpack/lib/action_controller/metal/params_wrapper.rb
@@ -82,7 +82,7 @@ module ActionController
# 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 ActionController
# # 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
diff --git a/actionpack/lib/action_controller/metal/redirecting.rb b/actionpack/lib/action_controller/metal/redirecting.rb
index ee0e69d87c..b23938e7d9 100644
--- a/actionpack/lib/action_controller/metal/redirecting.rb
+++ b/actionpack/lib/action_controller/metal/redirecting.rb
@@ -24,7 +24,7 @@ module ActionController
# * <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 ActionController
#
# 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 ActionController
# 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.
diff --git a/actionpack/lib/action_controller/metal/renderers.rb b/actionpack/lib/action_controller/metal/renderers.rb
index 78aeeef2bf..5272dc6cdb 100644
--- a/actionpack/lib/action_controller/metal/renderers.rb
+++ b/actionpack/lib/action_controller/metal/renderers.rb
@@ -52,8 +52,8 @@ module ActionController
# 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 @@ module ActionController
# @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
diff --git a/actionpack/lib/action_controller/metal/request_forgery_protection.rb b/actionpack/lib/action_controller/metal/request_forgery_protection.rb
index 17d4a793ac..a50f0ca8c1 100644
--- a/actionpack/lib/action_controller/metal/request_forgery_protection.rb
+++ b/actionpack/lib/action_controller/metal/request_forgery_protection.rb
@@ -19,7 +19,7 @@ module ActionController #: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 ActionController #:nodoc:
# 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 ActionController #:nodoc:
#
# 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:
#
diff --git a/actionpack/lib/action_controller/metal/responder.rb b/actionpack/lib/action_controller/metal/responder.rb
index 42a0959a58..891819968b 100644
--- a/actionpack/lib/action_controller/metal/responder.rb
+++ b/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 @@ module ActionController #:nodoc:
# 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)
diff --git a/actionpack/lib/action_controller/metal/streaming.rb b/actionpack/lib/action_controller/metal/streaming.rb
index 9f3c997024..4eb582648e 100644
--- a/actionpack/lib/action_controller/metal/streaming.rb
+++ b/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:
#
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 9f78e679c6..04dc1d37f7 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -361,7 +361,7 @@ module ActionController
# # 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
#
diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb
index 0cdd17bc2e..505f3b4e61 100644
--- a/actionpack/lib/action_controller/metal/url_for.rb
+++ b/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
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 7529993a0e..5aecb59df9 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -61,25 +61,25 @@ module ActionController
# 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 @@ module ActionController
# 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 @@ module ActionController
# 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 @@ module ActionController
#
# 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
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index 3d560518e1..2b5d3d85bf 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -44,8 +44,8 @@ module Mime
#
# 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
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb
index ba5d332d49..eaf922595a 100644
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -24,7 +24,7 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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.
diff --git a/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb b/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
index 019849ef95..3f28ea75ef 100644
--- a/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
+++ b/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
@@ -28,8 +28,8 @@ module ActionDispatch
# 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,
diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb
index 4b9d3141d5..c5043c5e7b 100644
--- a/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb
+++ b/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" %>
diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb
index 8c594c1523..a357a7ba11 100644
--- a/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb
+++ b/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
diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb
index c658559be9..a1b377f68c 100644
--- a/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb
+++ b/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" %>
diff --git a/actionpack/lib/action_dispatch/routing.rb b/actionpack/lib/action_dispatch/routing.rb
index 29090882a5..4417cb841a 100644
--- a/actionpack/lib/action_dispatch/routing.rb
+++ b/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
#
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 3e0bcfb5e8..045299281c 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -121,7 +121,7 @@ module ActionDispatch
# 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 @@ module ActionDispatch
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 @@ module ActionDispatch
# +: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 @@ module ActionDispatch
# [: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 @@ module ActionDispatch
# [: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 @@ module ActionDispatch
# <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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
#
# 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 ActionDispatch
#
# 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 ActionDispatch
# === 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# === 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
#
# 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 @@ module ActionDispatch
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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# [: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 @@ module ActionDispatch
# [: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 @@ module ActionDispatch
# === 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
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
index 3d7b8878b8..497ac3d545 100644
--- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
+++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -34,7 +34,7 @@ module ActionDispatch
# == 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 ActionDispatch
# 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 @@ module ActionDispatch
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
diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb
index 205ff44b1c..1ed5eb1dff 100644
--- a/actionpack/lib/action_dispatch/routing/redirection.rb
+++ b/actionpack/lib/action_dispatch/routing/redirection.rb
@@ -102,7 +102,7 @@ module ActionDispatch
#
# 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 ActionDispatch
# 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 ActionDispatch
# 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
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 060d0bfa2f..61071d1228 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -176,11 +176,11 @@ module ActionDispatch
#
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
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 @@ module ActionDispatch
@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'
diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb
index d4cd537048..76311c423a 100644
--- a/actionpack/lib/action_dispatch/routing/url_for.rb
+++ b/actionpack/lib/action_dispatch/routing/url_for.rb
@@ -18,8 +18,8 @@ module ActionDispatch
# 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 ActionDispatch
# 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 @@ module ActionDispatch
# 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
diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb
index b15e0446de..44ed0ac1f3 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/response.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -35,11 +35,11 @@ module ActionDispatch
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
diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
index 9de545b3c5..305bafc0c5 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
@@ -15,28 +15,28 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# +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)
diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
index 9388d44eef..2207a43afc 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -167,7 +167,7 @@ module ActionDispatch
# 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
diff --git a/actionpack/lib/action_dispatch/testing/assertions/tag.rb b/actionpack/lib/action_dispatch/testing/assertions/tag.rb
index 2e38266aba..e5fe30ba82 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/tag.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/tag.rb
@@ -49,44 +49,44 @@ module ActionDispatch
# * 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 @@ module ActionDispatch
# 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)
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index 56c7948d24..95cd89a166 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -430,8 +430,8 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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 @@ module ActionDispatch
# 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
diff --git a/actionpack/lib/action_dispatch/testing/test_process.rb b/actionpack/lib/action_dispatch/testing/test_process.rb
index 3a6d081721..9ad5a1bc1d 100644
--- a/actionpack/lib/action_dispatch/testing/test_process.rb
+++ b/actionpack/lib/action_dispatch/testing/test_process.rb
@@ -28,12 +28,12 @@ module ActionDispatch
# 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)
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 3464ec523e..668515df59 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/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:
#
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 4eac6514df..29a5ccedc1 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -24,7 +24,7 @@ module ActionView
# 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 ActionView
# 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 @@ module ActionView
# 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 @@ module ActionView
# # => <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 @@ module ActionView
# 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 @@ module ActionView
# # => <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 @@ module ActionView
# # => <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 @@ module ActionView
# <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>
diff --git a/actionpack/lib/action_view/helpers/atom_feed_helper.rb b/actionpack/lib/action_view/helpers/atom_feed_helper.rb
index f9aa8d7cee..f5ac455208 100644
--- a/actionpack/lib/action_view/helpers/atom_feed_helper.rb
+++ b/actionpack/lib/action_view/helpers/atom_feed_helper.rb
@@ -12,7 +12,7 @@ module ActionView
# 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 ActionView
# @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 ActionView
# @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 ActionView
# 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 @@ module ActionView
# 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
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb
index c98101a195..85e398e559 100644
--- a/actionpack/lib/action_view/helpers/capture_helper.rb
+++ b/actionpack/lib/action_view/helpers/capture_helper.rb
@@ -99,7 +99,7 @@ module ActionView
#
# 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 @@ module ActionView
# 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:
@@ -128,13 +128,13 @@ module ActionView
# If the flush parameter is true content_for replaces the blocks it is given. 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, flush: true 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 only the last link:
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index 61e39afd8e..459f95bb73 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -19,7 +19,7 @@ module ActionView
# of \date[month].
module DateHelper
# Reports the approximate distance in time between two Time, Date or DateTime objects or integers as seconds.
- # Pass <tt>:include_seconds => true</tt> if you want more detailed approximations when distance < 1 min, 29 secs.
+ # Pass <tt>include_seconds: true</tt> if you want more detailed approximations when distance < 1 min, 29 secs.
# Distances are reported based on the following table:
#
# 0 <-> 29 secs # => less than a minute
@@ -37,7 +37,7 @@ module ActionView
# 1 yr, 9 months <-> 2 yr minus 1 sec # => almost 2 years
# 2 yrs <-> max time or date # => (same rules as 1 yr)
#
- # With <tt>:include_seconds => true</tt> and the difference < 1 minute 29 seconds:
+ # With <tt>include_seconds: true</tt> and the difference < 1 minute 29 seconds:
# 0-4 secs # => less than 5 seconds
# 5-9 secs # => less than 10 seconds
# 10-19 secs # => less than 20 seconds
@@ -50,19 +50,19 @@ module ActionView
# distance_of_time_in_words(from_time, from_time + 50.minutes) # => about 1 hour
# distance_of_time_in_words(from_time, 50.minutes.from_now) # => about 1 hour
# distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute
- # distance_of_time_in_words(from_time, from_time + 15.seconds, :include_seconds => true) # => less than 20 seconds
+ # distance_of_time_in_words(from_time, from_time + 15.seconds, include_seconds: true) # => less than 20 seconds
# distance_of_time_in_words(from_time, 3.years.from_now) # => about 3 years
# distance_of_time_in_words(from_time, from_time + 60.hours) # => 3 days
- # distance_of_time_in_words(from_time, from_time + 45.seconds, :include_seconds => true) # => less than a minute
- # distance_of_time_in_words(from_time, from_time - 45.seconds, :include_seconds => true) # => less than a minute
+ # distance_of_time_in_words(from_time, from_time + 45.seconds, include_seconds: true) # => less than a minute
+ # distance_of_time_in_words(from_time, from_time - 45.seconds, include_seconds: true) # => less than a minute
# distance_of_time_in_words(from_time, 76.seconds.from_now) # => 1 minute
# distance_of_time_in_words(from_time, from_time + 1.year + 3.days) # => about 1 year
# distance_of_time_in_words(from_time, from_time + 3.years + 6.months) # => over 3 years
# distance_of_time_in_words(from_time, from_time + 4.years + 9.days + 30.minutes + 5.seconds) # => about 4 years
#
# to_time = Time.now + 6.years + 19.days
- # distance_of_time_in_words(from_time, to_time, :include_seconds => true) # => about 6 years
- # distance_of_time_in_words(to_time, from_time, :include_seconds => true) # => about 6 years
+ # distance_of_time_in_words(from_time, to_time, include_seconds: true) # => about 6 years
+ # distance_of_time_in_words(to_time, from_time, include_seconds: true) # => about 6 years
# distance_of_time_in_words(Time.now, Time.now) # => less than a minute
def distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options = {}, options = {})
if include_seconds_or_options.is_a?(Hash)
@@ -147,7 +147,7 @@ module ActionView
# time_ago_in_words(3.minutes.ago) # => 3 minutes
# time_ago_in_words(Time.now - 15.hours) # => about 15 hours
# time_ago_in_words(Time.now) # => less than a minute
- # time_ago_in_words(Time.now, :include_seconds => true) # => less than 5 seconds
+ # time_ago_in_words(Time.now, include_seconds: true) # => less than 5 seconds
#
# from_time = Time.now - 3.days - 14.minutes - 25.seconds
# time_ago_in_words(from_time) # => 3 days
@@ -190,7 +190,7 @@ module ActionView
# as a hidden field instead of showing a select field.
# * <tt>:order</tt> - Set to an array containing <tt>:day</tt>, <tt>:month</tt> and <tt>:year</tt> to
# customize the order in which the select fields are shown. If you leave out any of the symbols, the respective
- # select will not be shown (like when you set <tt>:discard_xxx => true</tt>. Defaults to the order defined in
+ # select will not be shown (like when you set <tt>discard_xxx: true</tt>. Defaults to the order defined in
# the respective locale (e.g. [:year, :month, :day] in the en locale that ships with Rails).
# * <tt>:include_blank</tt> - Include a blank option in every select field so it's possible to set empty
# dates.
@@ -212,36 +212,36 @@ module ActionView
#
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute,
# # with the year in the year drop down box starting at 1995.
- # date_select("article", "written_on", :start_year => 1995)
+ # date_select("article", "written_on", start_year: 1995)
#
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute,
# # with the year in the year drop down box starting at 1995, numbers used for months instead of words,
# # and without a day select box.
- # date_select("article", "written_on", :start_year => 1995, :use_month_numbers => true,
- # :discard_day => true, :include_blank => true)
+ # date_select("article", "written_on", start_year: 1995, use_month_numbers: true,
+ # discard_day: true, include_blank: true)
#
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute,
# # with two digit numbers used for months and days.
- # date_select("article", "written_on", :use_two_digit_numbers => true)
+ # date_select("article", "written_on", use_two_digit_numbers: true)
#
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute
# # with the fields ordered as day, month, year rather than month, day, year.
- # date_select("article", "written_on", :order => [:day, :month, :year])
+ # date_select("article", "written_on", order: [:day, :month, :year])
#
# # Generates a date select that when POSTed is stored in the user variable, in the birthday attribute
# # lacking a year field.
- # date_select("user", "birthday", :order => [:month, :day])
+ # date_select("user", "birthday", order: [:month, :day])
#
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute
# # which is initially set to the date 3 days from the current date
- # date_select("article", "written_on", :default => 3.days.from_now)
+ # date_select("article", "written_on", default: 3.days.from_now)
#
# # Generates a date select that when POSTed is stored in the credit_card variable, in the bill_due attribute
# # that will have a default day of 20.
- # date_select("credit_card", "bill_due", :default => { :day => 20 })
+ # date_select("credit_card", "bill_due", default: { day: 20 })
#
# # Generates a date select with custom prompts.
- # date_select("article", "written_on", :prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year' })
+ # date_select("article", "written_on", prompt: { day: 'Select day', month: 'Select month', year: 'Select year' })
#
# The selects are prepared for multi-parameter assignment to an Active Record object.
#
@@ -267,18 +267,18 @@ module ActionView
#
# # Creates a time select tag with a seconds field that, when POSTed, will be stored in the article variables in
# # the sunrise attribute.
- # time_select("article", "start_time", :include_seconds => true)
+ # time_select("article", "start_time", include_seconds: true)
#
# # You can set the <tt>:minute_step</tt> to 15 which will give you: 00, 15, 30 and 45.
- # time_select 'game', 'game_time', {:minute_step => 15}
+ # time_select 'game', 'game_time', {minute_step: 15}
#
- # # Creates a time select tag with a custom prompt. Use <tt>:prompt => true</tt> for generic prompts.
- # time_select("article", "written_on", :prompt => {:hour => 'Choose hour', :minute => 'Choose minute', :second => 'Choose seconds'})
- # time_select("article", "written_on", :prompt => {:hour => true}) # generic prompt for hours
- # time_select("article", "written_on", :prompt => true) # generic prompts for all
+ # # Creates a time select tag with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
+ # time_select("article", "written_on", prompt: {hour: 'Choose hour', minute: 'Choose minute', second: 'Choose seconds'})
+ # time_select("article", "written_on", prompt: {hour: true}) # generic prompt for hours
+ # time_select("article", "written_on", prompt: true) # generic prompts for all
#
# # You can set :ampm option to true which will show the hours as: 12 PM, 01 AM .. 11 PM.
- # time_select 'game', 'game_time', {:ampm => true}
+ # time_select 'game', 'game_time', {ampm: true}
#
# The selects are prepared for multi-parameter assignment to an Active Record object.
#
@@ -300,23 +300,23 @@ module ActionView
#
# # Generates a datetime select with a year select that starts at 1995 that, when POSTed, will be stored in the
# # article variable in the written_on attribute.
- # datetime_select("article", "written_on", :start_year => 1995)
+ # datetime_select("article", "written_on", start_year: 1995)
#
# # Generates a datetime select with a default value of 3 days from the current time that, when POSTed, will
# # be stored in the trip variable in the departing attribute.
- # datetime_select("trip", "departing", :default => 3.days.from_now)
+ # datetime_select("trip", "departing", default: 3.days.from_now)
#
# # Generate a datetime select with hours in the AM/PM format
- # datetime_select("article", "written_on", :ampm => true)
+ # datetime_select("article", "written_on", ampm: true)
#
# # Generates a datetime select that discards the type that, when POSTed, will be stored in the article variable
# # as the written_on attribute.
- # datetime_select("article", "written_on", :discard_type => true)
+ # datetime_select("article", "written_on", discard_type: true)
#
- # # Generates a datetime select with a custom prompt. Use <tt>:prompt => true</tt> for generic prompts.
- # datetime_select("article", "written_on", :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'})
- # datetime_select("article", "written_on", :prompt => {:hour => true}) # generic prompt for hours
- # datetime_select("article", "written_on", :prompt => true) # generic prompts for all
+ # # Generates a datetime select with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
+ # datetime_select("article", "written_on", prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
+ # datetime_select("article", "written_on", prompt: {hour: true}) # generic prompt for hours
+ # datetime_select("article", "written_on", prompt: true) # generic prompts for all
#
# The selects are prepared for multi-parameter assignment to an Active Record object.
def datetime_select(object_name, method, options = {}, html_options = {})
@@ -342,32 +342,32 @@ module ActionView
#
# # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
# # with the fields ordered year, month, day rather than month, day, year.
- # select_datetime(my_date_time, :order => [:year, :month, :day])
+ # select_datetime(my_date_time, order: [:year, :month, :day])
#
# # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
# # with a '/' between each date field.
- # select_datetime(my_date_time, :date_separator => '/')
+ # select_datetime(my_date_time, date_separator: '/')
#
# # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
# # with a date fields separated by '/', time fields separated by '' and the date and time fields
# # separated by a comma (',').
- # select_datetime(my_date_time, :date_separator => '/', :time_separator => '', :datetime_separator => ',')
+ # select_datetime(my_date_time, date_separator: '/', time_separator: '', datetime_separator: ',')
#
# # Generates a datetime select that discards the type of the field and defaults to the datetime in
# # my_date_time (four days after today)
- # select_datetime(my_date_time, :discard_type => true)
+ # select_datetime(my_date_time, discard_type: true)
#
# # Generate a datetime field with hours in the AM/PM format
- # select_datetime(my_date_time, :ampm => true)
+ # select_datetime(my_date_time, ampm: true)
#
# # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
# # prefixed with 'payday' rather than 'date'
- # select_datetime(my_date_time, :prefix => 'payday')
+ # select_datetime(my_date_time, prefix: 'payday')
#
- # # Generates a datetime select with a custom prompt. Use <tt>:prompt => true</tt> for generic prompts.
- # select_datetime(my_date_time, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'})
- # select_datetime(my_date_time, :prompt => {:hour => true}) # generic prompt for hours
- # select_datetime(my_date_time, :prompt => true) # generic prompts for all
+ # # Generates a datetime select with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
+ # select_datetime(my_date_time, prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
+ # select_datetime(my_date_time, prompt: {hour: true}) # generic prompt for hours
+ # select_datetime(my_date_time, prompt: true) # generic prompts for all
def select_datetime(datetime = Time.current, options = {}, html_options = {})
DateTimeSelector.new(datetime, options, html_options).select_datetime
end
@@ -389,24 +389,24 @@ module ActionView
#
# # Generates a date select that defaults to the date in my_date (six days after today)
# # with the fields ordered year, month, day rather than month, day, year.
- # select_date(my_date, :order => [:year, :month, :day])
+ # select_date(my_date, order: [:year, :month, :day])
#
# # Generates a date select that discards the type of the field and defaults to the date in
# # my_date (six days after today).
- # select_date(my_date, :discard_type => true)
+ # select_date(my_date, discard_type: true)
#
# # Generates a date select that defaults to the date in my_date,
# # which has fields separated by '/'.
- # select_date(my_date, :date_separator => '/')
+ # select_date(my_date, date_separator: '/')
#
# # Generates a date select that defaults to the datetime in my_date (six days after today)
# # prefixed with 'payday' rather than 'date'.
- # select_date(my_date, :prefix => 'payday')
+ # select_date(my_date, prefix: 'payday')
#
- # # Generates a date select with a custom prompt. Use <tt>:prompt => true</tt> for generic prompts.
- # select_date(my_date, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'})
- # select_date(my_date, :prompt => {:hour => true}) # generic prompt for hours
- # select_date(my_date, :prompt => true) # generic prompts for all
+ # # Generates a date select with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
+ # select_date(my_date, prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
+ # select_date(my_date, prompt: {hour: true}) # generic prompt for hours
+ # select_date(my_date, prompt: true) # generic prompts for all
def select_date(date = Date.current, options = {}, html_options = {})
DateTimeSelector.new(date, options, html_options).select_date
end
@@ -427,26 +427,26 @@ module ActionView
#
# # Generates a time select that defaults to the time in my_time,
# # which has fields separated by ':'.
- # select_time(my_time, :time_separator => ':')
+ # select_time(my_time, time_separator: ':')
#
# # Generates a time select that defaults to the time in my_time,
# # that also includes an input for seconds.
- # select_time(my_time, :include_seconds => true)
+ # select_time(my_time, include_seconds: true)
#
# # Generates a time select that defaults to the time in my_time, that has fields
# # separated by ':' and includes an input for seconds.
- # select_time(my_time, :time_separator => ':', :include_seconds => true)
+ # select_time(my_time, time_separator: ':', include_seconds: true)
#
# # Generate a time select field with hours in the AM/PM format
- # select_time(my_time, :ampm => true)
+ # select_time(my_time, ampm: true)
#
# # Generates a time select field with hours that range from 2 to 14
- # select_time(my_time, :start_hour => 2, :end_hour => 14)
+ # select_time(my_time, start_hour: 2, end_hour: 14)
#
# # Generates a time select with a custom prompt. Use <tt>:prompt</tt> to true for generic prompts.
- # select_time(my_time, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'})
- # select_time(my_time, :prompt => {:hour => true}) # generic prompt for hours
- # select_time(my_time, :prompt => true) # generic prompts for all
+ # select_time(my_time, prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
+ # select_time(my_time, prompt: {hour: true}) # generic prompt for hours
+ # select_time(my_time, prompt: true) # generic prompts for all
def select_time(datetime = Time.current, options = {}, html_options = {})
DateTimeSelector.new(datetime, options, html_options).select_time
end
@@ -465,11 +465,11 @@ module ActionView
#
# # Generates a select field for seconds that defaults to the seconds for the time in my_time
# # that is named 'interval' rather than 'second'.
- # select_second(my_time, :field_name => 'interval')
+ # select_second(my_time, field_name: 'interval')
#
- # # Generates a select field for seconds with a custom prompt. Use <tt>:prompt => true</tt> for a
+ # # Generates a select field for seconds with a custom prompt. Use <tt>prompt: true</tt> for a
# # generic prompt.
- # select_second(14, :prompt => 'Choose seconds')
+ # select_second(14, prompt: 'Choose seconds')
def select_second(datetime, options = {}, html_options = {})
DateTimeSelector.new(datetime, options, html_options).select_second
end
@@ -489,11 +489,11 @@ module ActionView
#
# # Generates a select field for minutes that defaults to the minutes for the time in my_time
# # that is named 'moment' rather than 'minute'.
- # select_minute(my_time, :field_name => 'moment')
+ # select_minute(my_time, field_name: 'moment')
#
- # # Generates a select field for minutes with a custom prompt. Use <tt>:prompt => true</tt> for a
+ # # Generates a select field for minutes with a custom prompt. Use <tt>prompt: true</tt> for a
# # generic prompt.
- # select_minute(14, :prompt => 'Choose minutes')
+ # select_minute(14, prompt: 'Choose minutes')
def select_minute(datetime, options = {}, html_options = {})
DateTimeSelector.new(datetime, options, html_options).select_minute
end
@@ -512,17 +512,17 @@ module ActionView
#
# # Generates a select field for hours that defaults to the hour for the time in my_time
# # that is named 'stride' rather than 'hour'.
- # select_hour(my_time, :field_name => 'stride')
+ # select_hour(my_time, field_name: 'stride')
#
- # # Generates a select field for hours with a custom prompt. Use <tt>:prompt => true</tt> for a
+ # # Generates a select field for hours with a custom prompt. Use <tt>prompt: true</tt> for a
# # generic prompt.
- # select_hour(13, :prompt => 'Choose hour')
+ # select_hour(13, prompt: 'Choose hour')
#
# # Generate a select field for hours in the AM/PM format
- # select_hour(my_time, :ampm => true)
+ # select_hour(my_time, ampm: true)
#
# # Generates a select field that includes options for hours from 2 to 14.
- # select_hour(my_time, :start_hour => 2, :end_hour => 14)
+ # select_hour(my_time, start_hour: 2, end_hour: 14)
def select_hour(datetime, options = {}, html_options = {})
DateTimeSelector.new(datetime, options, html_options).select_hour
end
@@ -541,15 +541,15 @@ module ActionView
# select_day(5)
#
# # Generates a select field for days that defaults to the number given, but displays it with two digits.
- # select_day(5, :use_two_digit_numbers => true)
+ # select_day(5, use_two_digit_numbers: true)
#
# # Generates a select field for days that defaults to the day for the date in my_date
# # that is named 'due' rather than 'day'.
- # select_day(my_time, :field_name => 'due')
+ # select_day(my_time, field_name: 'due')
#
- # # Generates a select field for days with a custom prompt. Use <tt>:prompt => true</tt> for a
+ # # Generates a select field for days with a custom prompt. Use <tt>prompt: true</tt> for a
# # generic prompt.
- # select_day(5, :prompt => 'Choose day')
+ # select_day(5, prompt: 'Choose day')
def select_day(date, options = {}, html_options = {})
DateTimeSelector.new(date, options, html_options).select_day
end
@@ -570,31 +570,31 @@ module ActionView
#
# # Generates a select field for months that defaults to the current month that
# # is named "start" rather than "month".
- # select_month(Date.today, :field_name => 'start')
+ # select_month(Date.today, field_name: 'start')
#
# # Generates a select field for months that defaults to the current month that
# # will use keys like "1", "3".
- # select_month(Date.today, :use_month_numbers => true)
+ # select_month(Date.today, use_month_numbers: true)
#
# # Generates a select field for months that defaults to the current month that
# # will use keys like "1 - January", "3 - March".
- # select_month(Date.today, :add_month_numbers => true)
+ # select_month(Date.today, add_month_numbers: true)
#
# # Generates a select field for months that defaults to the current month that
# # will use keys like "Jan", "Mar".
- # select_month(Date.today, :use_short_month => true)
+ # select_month(Date.today, use_short_month: true)
#
# # Generates a select field for months that defaults to the current month that
# # will use keys like "Januar", "Marts."
- # select_month(Date.today, :use_month_names => %w(Januar Februar Marts ...))
+ # select_month(Date.today, use_month_names: %w(Januar Februar Marts ...))
#
# # Generates a select field for months that defaults to the current month that
# # will use keys with two digit numbers like "01", "03".
- # select_month(Date.today, :use_two_digit_numbers => true)
+ # select_month(Date.today, use_two_digit_numbers: true)
#
- # # Generates a select field for months with a custom prompt. Use <tt>:prompt => true</tt> for a
+ # # Generates a select field for months with a custom prompt. Use <tt>prompt: true</tt> for a
# # generic prompt.
- # select_month(14, :prompt => 'Choose month')
+ # select_month(14, prompt: 'Choose month')
def select_month(date, options = {}, html_options = {})
DateTimeSelector.new(date, options, html_options).select_month
end
@@ -607,23 +607,23 @@ module ActionView
#
# # Generates a select field for years that defaults to the current year that
# # has ascending year values.
- # select_year(Date.today, :start_year => 1992, :end_year => 2007)
+ # select_year(Date.today, start_year: 1992, end_year: 2007)
#
# # Generates a select field for years that defaults to the current year that
# # is named 'birth' rather than 'year'.
- # select_year(Date.today, :field_name => 'birth')
+ # select_year(Date.today, field_name: 'birth')
#
# # Generates a select field for years that defaults to the current year that
# # has descending year values.
- # select_year(Date.today, :start_year => 2005, :end_year => 1900)
+ # select_year(Date.today, start_year: 2005, end_year: 1900)
#
# # Generates a select field for years that defaults to the year 2006 that
# # has ascending year values.
- # select_year(2006, :start_year => 2000, :end_year => 2010)
+ # select_year(2006, start_year: 2000, end_year: 2010)
#
- # # Generates a select field for years with a custom prompt. Use <tt>:prompt => true</tt> for a
+ # # Generates a select field for years with a custom prompt. Use <tt>prompt: true</tt> for a
# # generic prompt.
- # select_year(14, :prompt => 'Choose year')
+ # select_year(14, prompt: 'Choose year')
def select_year(date, options = {}, html_options = {})
DateTimeSelector.new(date, options, html_options).select_year
end
@@ -636,7 +636,7 @@ module ActionView
# <time datetime="2010-11-04T17:55:45+01:00">November 04, 2010 17:55</time>
# time_tag Date.yesterday, 'Yesterday' # =>
# <time datetime="2010-11-03">Yesterday</time>
- # time_tag Date.today, :pubdate => true # =>
+ # time_tag Date.today, pubdate: true # =>
# <time datetime="2010-11-04" pubdate="pubdate">November 04, 2010</time>
#
# <%= time_tag Time.now do %>
@@ -893,19 +893,19 @@ module ActionView
end
# Build select option html from date value and options.
- # build_options(15, :start => 1, :end => 31)
+ # build_options(15, start: 1, end: 31)
# => "<option value="1">1</option>
# <option value="2">2</option>
# <option value="3">3</option>..."
#
- # If <tt>:use_two_digit_numbers => true</tt> option is passed
- # build_options(15, :start => 1, :end => 31, :use_two_digit_numbers => true)
+ # If <tt>use_two_digit_numbers: true</tt> option is passed
+ # build_options(15, start: 1, end: 31, use_two_digit_numbers: true)
# => "<option value="1">01</option>
# <option value="2">02</option>
# <option value="3">03</option>..."
#
# If <tt>:step</tt> options is passed
- # build_options(15, :start => 1, :end => 31, :step => 2)
+ # build_options(15, start: 1, end: 31, step: 2)
# => "<option value="1">1</option>
# <option value="3">3</option>
# <option value="5">5</option>..."
@@ -954,7 +954,7 @@ module ActionView
end
# Builds a prompt option tag with supplied options or from default options.
- # prompt_option_tag(:month, :prompt => 'Select month')
+ # prompt_option_tag(:month, prompt: 'Select month')
# => "<option value="">Select month</option>"
def prompt_option_tag(type, options)
prompt = case options
diff --git a/actionpack/lib/action_view/helpers/debug_helper.rb b/actionpack/lib/action_view/helpers/debug_helper.rb
index d8b92c5cab..d361a69a92 100644
--- a/actionpack/lib/action_view/helpers/debug_helper.rb
+++ b/actionpack/lib/action_view/helpers/debug_helper.rb
@@ -11,7 +11,7 @@ module ActionView
# If the object cannot be converted to YAML using +to_yaml+, +inspect+ will be called instead.
# Useful for inspecting an object at the time of rendering.
#
- # @user = User.new({ :username => 'testing', :password => 'xyz', :age => 42}) %>
+ # @user = User.new({ username: 'testing', password: 'xyz', age: 42}) %>
# debug(@user)
# # =>
# <pre class='debug_dump'>--- !ruby/object:User
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 87f4380baf..b7b3db959e 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -14,7 +14,7 @@ module ActionView
#
# For example,
#
- # select("post", "category", Post::CATEGORIES, {:include_blank => true})
+ # select("post", "category", Post::CATEGORIES, {include_blank: true})
#
# could become:
#
@@ -28,7 +28,7 @@ module ActionView
#
# Example with @post.person_id => 2:
#
- # select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, {:include_blank => 'None'})
+ # select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, {include_blank: 'None'})
#
# could become:
#
@@ -43,7 +43,7 @@ module ActionView
#
# Example:
#
- # select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, {:prompt => 'Select Person'})
+ # select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, {prompt: 'Select Person'})
#
# could become:
#
@@ -59,7 +59,7 @@ module ActionView
#
# Example:
#
- # select("album[]", "genre", %w[rap rock country], {}, { :index => nil })
+ # select("album[]", "genre", %w[rap rock country], {}, { index: nil })
#
# becomes:
#
@@ -73,7 +73,7 @@ module ActionView
#
# Example:
#
- # select("post", "category", Post::CATEGORIES, {:disabled => 'restricted'})
+ # select("post", "category", Post::CATEGORIES, {disabled: 'restricted'})
#
# could become:
#
@@ -88,7 +88,7 @@ module ActionView
#
# Example:
#
- # collection_select(:post, :category_id, Category.all, :id, :name, {:disabled => lambda{|category| category.archived? }})
+ # collection_select(:post, :category_id, Category.all, :id, :name, {disabled: lambda{|category| category.archived? }})
#
# If the categories "2008 stuff" and "Christmas" return true when the method <tt>archived?</tt> is called, this would return:
# <select name="post[category_id]">
@@ -110,7 +110,7 @@ module ActionView
# * A nested collection: see grouped_options_for_select
#
# Example with @post.person_id => 1:
- # select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, { :include_blank => true })
+ # select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, { include_blank: true })
#
# could become:
#
@@ -127,8 +127,8 @@ module ActionView
# This allows the user to submit a form page more than once with the expected results of creating multiple records.
# In addition, this allows a single partial to be used to generate form inputs for both edit and create forms.
#
- # By default, <tt>post.person_id</tt> is the selected option. Specify <tt>:selected => value</tt> to use a different selection
- # or <tt>:selected => nil</tt> to leave all options unselected. Similarly, you can specify values to be disabled in the option
+ # By default, <tt>post.person_id</tt> is the selected option. Specify <tt>selected: value</tt> to use a different selection
+ # or <tt>selected: nil</tt> to leave all options unselected. Similarly, you can specify values to be disabled in the option
# tags by specifying the <tt>:disabled</tt> option. This can either be a single value or an array of values to be disabled.
#
# ==== Gotcha
@@ -152,7 +152,7 @@ module ActionView
# form, and parameters extraction gets the last occurrence of any repeated
# key in the query string, that works for ordinary forms.
#
- # In case if you don't want the helper to generate this hidden field you can specify <tt>:include_blank => false</tt> option.
+ # In case if you don't want the helper to generate this hidden field you can specify <tt>include_blank: false</tt> option.
#
def select(object, method, choices, options = {}, html_options = {})
Tags::Select.new(object, method, self, choices, options, html_options).render
@@ -181,7 +181,7 @@ module ActionView
# end
#
# Sample usage (selecting the associated Author for an instance of Post, <tt>@post</tt>):
- # collection_select(:post, :author_id, Author.all, :id, :name_with_initial, :prompt => true)
+ # collection_select(:post, :author_id, Author.all, :id, :name_with_initial, prompt: true)
#
# If <tt>@post.author_id</tt> is already <tt>1</tt>, this would return:
# <select name="post[author_id]">
@@ -263,17 +263,17 @@ module ActionView
# Finally, this method supports a <tt>:default</tt> option, which selects
# a default ActiveSupport::TimeZone if the object's time zone is +nil+.
#
- # time_zone_select( "user", "time_zone", nil, :include_blank => true)
+ # time_zone_select( "user", "time_zone", nil, include_blank: true)
#
- # time_zone_select( "user", "time_zone", nil, :default => "Pacific Time (US & Canada)" )
+ # time_zone_select( "user", "time_zone", nil, default: "Pacific Time (US & Canada)" )
#
- # time_zone_select( "user", 'time_zone', ActiveSupport::TimeZone.us_zones, :default => "Pacific Time (US & Canada)")
+ # time_zone_select( "user", 'time_zone', ActiveSupport::TimeZone.us_zones, default: "Pacific Time (US & Canada)")
#
# time_zone_select( "user", 'time_zone', [ ActiveSupport::TimeZone['Alaska'], ActiveSupport::TimeZone['Hawaii'] ])
#
# time_zone_select( "user", 'time_zone', /Australia/)
#
- # time_zone_select( "user", "time_zone", ActiveSupport::TimeZone.all.sort, :model => ActiveSupport::TimeZone)
+ # time_zone_select( "user", "time_zone", ActiveSupport::TimeZone.all.sort, model: ActiveSupport::TimeZone)
def time_zone_select(object, method, priority_zones = nil, options = {}, html_options = {})
Tags::TimeZoneSelect.new(object, method, self, priority_zones, options, html_options).render
end
@@ -305,12 +305,12 @@ module ActionView
# You can optionally provide html attributes as the last element of the array.
#
# Examples:
- # options_for_select([ "Denmark", ["USA", {:class => 'bold'}], "Sweden" ], ["USA", "Sweden"])
+ # options_for_select([ "Denmark", ["USA", {class: 'bold'}], "Sweden" ], ["USA", "Sweden"])
# # <option value="Denmark">Denmark</option>
# # <option value="USA" class="bold" selected="selected">USA</option>
# # <option value="Sweden" selected="selected">Sweden</option>
#
- # options_for_select([["Dollar", "$", {:class => "bold"}], ["Kroner", "DKK", {:onclick => "alert('HI');"}]])
+ # options_for_select([["Dollar", "$", {class: "bold"}], ["Kroner", "DKK", {onclick: "alert('HI');"}]])
# # <option value="$" class="bold">Dollar</option>
# # <option value="DKK" onclick="alert('HI');">Kroner</option>
#
@@ -318,19 +318,19 @@ module ActionView
# or array of values to be disabled. In this case, you can use <tt>:selected</tt> to specify selected option tags.
#
# Examples:
- # options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], :disabled => "Super Platinum")
+ # options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], disabled: "Super Platinum")
# # <option value="Free">Free</option>
# # <option value="Basic">Basic</option>
# # <option value="Advanced">Advanced</option>
# # <option value="Super Platinum" disabled="disabled">Super Platinum</option>
#
- # options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], :disabled => ["Advanced", "Super Platinum"])
+ # options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], disabled: ["Advanced", "Super Platinum"])
# # <option value="Free">Free</option>
# # <option value="Basic">Basic</option>
# # <option value="Advanced" disabled="disabled">Advanced</option>
# # <option value="Super Platinum" disabled="disabled">Super Platinum</option>
#
- # options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], :selected => "Free", :disabled => "Super Platinum")
+ # options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], selected: "Free", disabled: "Super Platinum")
# # <option value="Free" selected="selected">Free</option>
# # <option value="Basic">Basic</option>
# # <option value="Advanced">Advanced</option>
@@ -632,7 +632,7 @@ module ActionView
# The builder methods <tt>label</tt> and <tt>radio_button</tt> also accept
# extra html options:
# collection_radio_buttons(:post, :author_id, Author.all, :id, :name_with_initial) do |b|
- # b.label(:class => "radio_button") { b.radio_button(:class => "radio_button") }
+ # b.label(class: "radio_button") { b.radio_button(class: "radio_button") }
# end
#
# There are also three special methods available: <tt>object</tt>, <tt>text</tt> and
@@ -695,7 +695,7 @@ module ActionView
# The builder methods <tt>label</tt> and <tt>check_box</tt> also accept
# extra html options:
# collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
- # b.label(:class => "check_box") { b.check_box(:class => "check_box") }
+ # b.label(class: "check_box") { b.check_box(class: "check_box") }
# end
#
# There are also three special methods available: <tt>object</tt>, <tt>text</tt> and
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 7680208702..7f42d6e9c3 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -10,7 +10,7 @@ module ActionView
# FormHelper does. Instead, you provide the names and values manually.
#
# NOTE: The HTML options <tt>disabled</tt>, <tt>readonly</tt>, and <tt>multiple</tt> can all be treated as booleans. So specifying
- # <tt>:disabled => true</tt> will give <tt>disabled="disabled"</tt>.
+ # <tt>disabled: true</tt> will give <tt>disabled="disabled"</tt>.
module FormTagHelper
extend ActiveSupport::Concern
@@ -43,10 +43,10 @@ module ActionView
# form_tag('/posts')
# # => <form action="/posts" method="post">
#
- # form_tag('/posts/1', :method => :put)
+ # form_tag('/posts/1', method: :put)
# # => <form action="/posts/1" method="post"> ... <input name="_method" type="hidden" value="put" /> ...
#
- # form_tag('/upload', :multipart => true)
+ # form_tag('/upload', multipart: true)
# # => <form action="/upload" method="post" enctype="multipart/form-data">
#
# <%= form_tag('/posts') do -%>
@@ -54,13 +54,13 @@ module ActionView
# <% end -%>
# # => <form action="/posts" method="post"><div><input type="submit" name="submit" value="Save" /></div></form>
#
- # <%= form_tag('/posts', :remote => true) %>
+ # <%= form_tag('/posts', remote: true) %>
# # => <form action="/posts" method="post" data-remote="true">
#
- # form_tag('http://far.away.com/form', :authenticity_token => false)
+ # form_tag('http://far.away.com/form', authenticity_token: false)
# # form without authenticity token
#
- # form_tag('http://far.away.com/form', :authenticity_token => "cf50faa3fe97702ca1ae")
+ # form_tag('http://far.away.com/form', authenticity_token: "cf50faa3fe97702ca1ae")
# # form with custom authenticity token
#
def form_tag(url_for_options = {}, options = {}, &block)
@@ -96,7 +96,7 @@ module ActionView
# # => <select id="count" name="count"><option>1</option><option>2</option>
# # <option>3</option><option>4</option></select>
#
- # select_tag "colors", "<option>Red</option><option>Green</option><option>Blue</option>".html_safe, :multiple => true
+ # select_tag "colors", "<option>Red</option><option>Green</option><option>Blue</option>".html_safe, multiple: true
# # => <select id="colors" multiple="multiple" name="colors[]"><option>Red</option>
# # <option>Green</option><option>Blue</option></select>
#
@@ -104,17 +104,17 @@ module ActionView
# # => <select id="locations" name="locations"><option>Home</option><option selected='selected'>Work</option>
# # <option>Out</option></select>
#
- # select_tag "access", "<option>Read</option><option>Write</option>".html_safe, :multiple => true, :class => 'form_input'
+ # select_tag "access", "<option>Read</option><option>Write</option>".html_safe, multiple: true, class: 'form_input'
# # => <select class="form_input" id="access" multiple="multiple" name="access[]"><option>Read</option>
# # <option>Write</option></select>
#
- # select_tag "people", options_from_collection_for_select(@people, "id", "name"), :include_blank => true
+ # select_tag "people", options_from_collection_for_select(@people, "id", "name"), include_blank: true
# # => <select id="people" name="people"><option value=""></option><option value="1">David</option></select>
#
- # select_tag "people", options_from_collection_for_select(@people, "id", "name"), :prompt => "Select something"
+ # select_tag "people", options_from_collection_for_select(@people, "id", "name"), prompt: "Select something"
# # => <select id="people" name="people"><option value="">Select something</option><option value="1">David</option></select>
#
- # select_tag "destination", "<option>NYC</option><option>Paris</option><option>Rome</option>".html_safe, :disabled => true
+ # select_tag "destination", "<option>NYC</option><option>Paris</option><option>Rome</option>".html_safe, disabled: true
# # => <select disabled="disabled" id="destination" name="destination"><option>NYC</option>
# # <option>Paris</option><option>Rome</option></select>
#
@@ -153,22 +153,22 @@ module ActionView
# text_field_tag 'query', 'Enter your search query here'
# # => <input id="query" name="query" type="text" value="Enter your search query here" />
#
- # text_field_tag 'search', nil, :placeholder => 'Enter search term...'
+ # text_field_tag 'search', nil, placeholder: 'Enter search term...'
# # => <input id="search" name="search" placeholder="Enter search term..." type="text" />
#
- # text_field_tag 'request', nil, :class => 'special_input'
+ # text_field_tag 'request', nil, class: 'special_input'
# # => <input class="special_input" id="request" name="request" type="text" />
#
- # text_field_tag 'address', '', :size => 75
+ # text_field_tag 'address', '', size: 75
# # => <input id="address" name="address" size="75" type="text" value="" />
#
- # text_field_tag 'zip', nil, :maxlength => 5
+ # text_field_tag 'zip', nil, maxlength: 5
# # => <input id="zip" maxlength="5" name="zip" type="text" />
#
- # text_field_tag 'payment_amount', '$0.00', :disabled => true
+ # text_field_tag 'payment_amount', '$0.00', disabled: true
# # => <input disabled="disabled" id="payment_amount" name="payment_amount" type="text" value="$0.00" />
#
- # text_field_tag 'ip', '0.0.0.0', :maxlength => 15, :size => 20, :class => "ip-input"
+ # text_field_tag 'ip', '0.0.0.0', maxlength: 15, size: 20, class: "ip-input"
# # => <input class="ip-input" id="ip" maxlength="15" name="ip" size="20" type="text" value="0.0.0.0" />
def text_field_tag(name, value = nil, options = {})
tag :input, { "type" => "text", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys)
@@ -186,7 +186,7 @@ module ActionView
# label_tag 'name', 'Your name'
# # => <label for="name">Your Name</label>
#
- # label_tag 'name', nil, :class => 'small_label'
+ # label_tag 'name', nil, class: 'small_label'
# # => <label for="name" class="small_label">Name</label>
def label_tag(name = nil, content_or_options = nil, options = nil, &block)
if block_given? && content_or_options.is_a?(Hash)
@@ -212,7 +212,7 @@ module ActionView
# hidden_field_tag 'token', 'VUBJKB23UIVI1UU1VOBVI@'
# # => <input id="token" name="token" type="hidden" value="VUBJKB23UIVI1UU1VOBVI@" />
#
- # hidden_field_tag 'collected_input', '', :onchange => "alert('Input collected!')"
+ # hidden_field_tag 'collected_input', '', onchange: "alert('Input collected!')"
# # => <input id="collected_input" name="collected_input" onchange="alert('Input collected!')"
# # type="hidden" value="" />
def hidden_field_tag(name, value = nil, options = {})
@@ -222,7 +222,7 @@ module ActionView
# Creates a file upload field. If you are using file uploads then you will also need
# to set the multipart option for the form tag:
#
- # <%= form_tag '/upload', :multipart => true do %>
+ # <%= form_tag '/upload', multipart: true do %>
# <label for="file">File to Upload</label> <%= file_field_tag "file" %>
# <%= submit_tag %>
# <% end %>
@@ -238,19 +238,19 @@ module ActionView
# file_field_tag 'attachment'
# # => <input id="attachment" name="attachment" type="file" />
#
- # file_field_tag 'avatar', :class => 'profile_input'
+ # file_field_tag 'avatar', class: 'profile_input'
# # => <input class="profile_input" id="avatar" name="avatar" type="file" />
#
- # file_field_tag 'picture', :disabled => true
+ # file_field_tag 'picture', disabled: true
# # => <input disabled="disabled" id="picture" name="picture" type="file" />
#
- # file_field_tag 'resume', :value => '~/resume.doc'
+ # file_field_tag 'resume', value: '~/resume.doc'
# # => <input id="resume" name="resume" type="file" value="~/resume.doc" />
#
- # file_field_tag 'user_pic', :accept => 'image/png,image/gif,image/jpeg'
+ # file_field_tag 'user_pic', accept: 'image/png,image/gif,image/jpeg'
# # => <input accept="image/png,image/gif,image/jpeg" id="user_pic" name="user_pic" type="file" />
#
- # file_field_tag 'file', :accept => 'text/html', :class => 'upload', :value => 'index.html'
+ # file_field_tag 'file', accept: 'text/html', class: 'upload', value: 'index.html'
# # => <input accept="text/html" class="upload" id="file" name="file" type="file" value="index.html" />
def file_field_tag(name, options = {})
text_field_tag(name, nil, options.update("type" => "file"))
@@ -271,19 +271,19 @@ module ActionView
# password_field_tag 'secret', 'Your secret here'
# # => <input id="secret" name="secret" type="password" value="Your secret here" />
#
- # password_field_tag 'masked', nil, :class => 'masked_input_field'
+ # password_field_tag 'masked', nil, class: 'masked_input_field'
# # => <input class="masked_input_field" id="masked" name="masked" type="password" />
#
- # password_field_tag 'token', '', :size => 15
+ # password_field_tag 'token', '', size: 15
# # => <input id="token" name="token" size="15" type="password" value="" />
#
- # password_field_tag 'key', nil, :maxlength => 16
+ # password_field_tag 'key', nil, maxlength: 16
# # => <input id="key" maxlength="16" name="key" type="password" />
#
- # password_field_tag 'confirm_pass', nil, :disabled => true
+ # password_field_tag 'confirm_pass', nil, disabled: true
# # => <input disabled="disabled" id="confirm_pass" name="confirm_pass" type="password" />
#
- # password_field_tag 'pin', '1234', :maxlength => 4, :size => 6, :class => "pin_input"
+ # password_field_tag 'pin', '1234', maxlength: 4, size: 6, class: "pin_input"
# # => <input class="pin_input" id="pin" maxlength="4" name="pin" size="6" type="password" value="1234" />
def password_field_tag(name = "password", value = nil, options = {})
text_field_tag(name, value, options.update("type" => "password"))
@@ -307,16 +307,16 @@ module ActionView
# text_area_tag 'bio', @user.bio
# # => <textarea id="bio" name="bio">This is my biography.</textarea>
#
- # text_area_tag 'body', nil, :rows => 10, :cols => 25
+ # text_area_tag 'body', nil, rows: 10, cols: 25
# # => <textarea cols="25" id="body" name="body" rows="10"></textarea>
#
- # text_area_tag 'body', nil, :size => "25x10"
+ # text_area_tag 'body', nil, size: "25x10"
# # => <textarea name="body" id="body" cols="25" rows="10"></textarea>
#
- # text_area_tag 'description', "Description goes here.", :disabled => true
+ # text_area_tag 'description', "Description goes here.", disabled: true
# # => <textarea disabled="disabled" id="description" name="description">Description goes here.</textarea>
#
- # text_area_tag 'comment', nil, :class => 'comment_input'
+ # text_area_tag 'comment', nil, class: 'comment_input'
# # => <textarea class="comment_input" id="comment" name="comment"></textarea>
def text_area_tag(name, content = nil, options = {})
options = options.stringify_keys
@@ -347,10 +347,10 @@ module ActionView
# check_box_tag 'receive_email', 'yes', true
# # => <input checked="checked" id="receive_email" name="receive_email" type="checkbox" value="yes" />
#
- # check_box_tag 'tos', 'yes', false, :class => 'accept_tos'
+ # check_box_tag 'tos', 'yes', false, class: 'accept_tos'
# # => <input class="accept_tos" id="tos" name="tos" type="checkbox" value="yes" />
#
- # check_box_tag 'eula', 'accepted', false, :disabled => true
+ # check_box_tag 'eula', 'accepted', false, disabled: true
# # => <input disabled="disabled" id="eula" name="eula" type="checkbox" value="accepted" />
def check_box_tag(name, value = "1", checked = false, options = {})
html_options = { "type" => "checkbox", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys)
@@ -372,10 +372,10 @@ module ActionView
# radio_button_tag 'receive_updates', 'no', true
# # => <input checked="checked" id="receive_updates_no" name="receive_updates" type="radio" value="no" />
#
- # radio_button_tag 'time_slot', "3:00 p.m.", false, :disabled => true
+ # radio_button_tag 'time_slot', "3:00 p.m.", false, disabled: true
# # => <input disabled="disabled" id="time_slot_300_pm" name="time_slot" type="radio" value="3:00 p.m." />
#
- # radio_button_tag 'color', "green", true, :class => "color_input"
+ # radio_button_tag 'color', "green", true, class: "color_input"
# # => <input checked="checked" class="color_input" id="color_green" name="color" type="radio" value="green" />
def radio_button_tag(name, value, checked = false, options = {})
html_options = { "type" => "radio", "name" => name, "id" => "#{sanitize_to_id(name)}_#{sanitize_to_id(value)}", "value" => value }.update(options.stringify_keys)
@@ -392,7 +392,7 @@ module ActionView
#
# ==== Data attributes
#
- # * <tt>:confirm => 'question?'</tt> - If present the unobtrusive JavaScript
+ # * <tt>confirm: 'question?'</tt> - If present the unobtrusive JavaScript
# drivers will provide a prompt with the question specified. If the user accepts,
# the form is processed normally, otherwise no action is taken.
# * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a
@@ -406,19 +406,19 @@ module ActionView
# submit_tag "Edit this article"
# # => <input name="commit" type="submit" value="Edit this article" />
#
- # submit_tag "Save edits", :disabled => true
+ # submit_tag "Save edits", disabled: true
# # => <input disabled="disabled" name="commit" type="submit" value="Save edits" />
#
- # submit_tag "Complete sale", :data => { :disable_with => "Please wait..." }
+ # submit_tag "Complete sale", data: { disable_with: "Please wait..." }
# # => <input name="commit" data-disable-with="Please wait..." type="submit" value="Complete sale" />
#
- # submit_tag nil, :class => "form_submit"
+ # submit_tag nil, class: "form_submit"
# # => <input class="form_submit" name="commit" type="submit" />
#
- # submit_tag "Edit", :class => "edit_button"
+ # submit_tag "Edit", class: "edit_button"
# # => <input class="edit_button" name="commit" type="submit" value="Edit" />
#
- # submit_tag "Save", :data => { :confirm => "Are you sure?" }
+ # submit_tag "Save", data: { confirm: "Are you sure?" }
# # => <input name='commit' type='submit' value='Save' data-confirm="Are you sure?" />
#
def submit_tag(value = "Save changes", options = {})
@@ -458,7 +458,7 @@ module ActionView
#
# ==== Data attributes
#
- # * <tt>:confirm => 'question?'</tt> - If present, the
+ # * <tt>confirm: 'question?'</tt> - If present, the
# unobtrusive JavaScript drivers will provide a prompt with
# the question specified. If the user accepts, the form is
# processed normally, otherwise no action is taken.
@@ -471,14 +471,14 @@ module ActionView
# button_tag
# # => <button name="button" type="submit">Button</button>
#
- # button_tag(:type => 'button') do
+ # button_tag(type: 'button') do
# content_tag(:strong, 'Ask me!')
# end
# # => <button name="button" type="button">
# # <strong>Ask me!</strong>
# # </button>
#
- # button_tag "Checkout", :data => { disable_with => "Please wait..." }
+ # button_tag "Checkout", data: { disable_with => "Please wait..." }
# # => <button data-disable-with="Please wait..." name="button" type="submit">Checkout</button>
#
def button_tag(content_or_options = nil, options = nil, &block)
@@ -518,7 +518,7 @@ module ActionView
#
# ==== Data attributes
#
- # * <tt>:confirm => 'question?'</tt> - This will add a JavaScript confirm
+ # * <tt>confirm: 'question?'</tt> - This will add a JavaScript confirm
# prompt with the question specified. If the user accepts, the form is
# processed normally, otherwise no action is taken.
#
@@ -526,16 +526,16 @@ module ActionView
# image_submit_tag("login.png")
# # => <input src="/images/login.png" type="image" />
#
- # image_submit_tag("purchase.png", :disabled => true)
+ # image_submit_tag("purchase.png", disabled: true)
# # => <input disabled="disabled" src="/images/purchase.png" type="image" />
#
- # image_submit_tag("search.png", :class => 'search_button')
+ # image_submit_tag("search.png", class: 'search_button')
# # => <input class="search_button" src="/images/search.png" type="image" />
#
- # image_submit_tag("agree.png", :disabled => true, :class => "agree_disagree_button")
+ # image_submit_tag("agree.png", disabled: true, class: "agree_disagree_button")
# # => <input class="agree_disagree_button" disabled="disabled" src="/images/agree.png" type="image" />
#
- # image_submit_tag("save.png", :data => { :confirm => "Are you sure?" })
+ # image_submit_tag("save.png", data: { confirm: "Are you sure?" })
# # => <input src="/images/save.png" data-confirm="Are you sure?" type="image" />
def image_submit_tag(source, options = {})
options = options.stringify_keys
@@ -567,7 +567,7 @@ module ActionView
# <% end %>
# # => <fieldset><legend>Your details</legend><p><input id="name" name="name" type="text" /></p></fieldset>
#
- # <%= field_set_tag nil, :class => 'format' do %>
+ # <%= field_set_tag nil, class: 'format' do %>
# <p><%= text_field_tag 'name' %></p>
# <% end %>
# # => <fieldset class="format"><p><input id="name" name="name" type="text" /></p></fieldset>
@@ -693,7 +693,7 @@ module ActionView
# * Otherwise accepts the same options as text_field_tag.
#
# ==== Examples
- # number_field_tag 'quantity', nil, :in => 1...10
+ # number_field_tag 'quantity', nil, in: 1...10
# # => <input id="quantity" name="quantity" min="1" max="9" type="number" />
def number_field_tag(name, value = nil, options = {})
options = options.stringify_keys
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb
index 7bf659d5f2..1a99fc7091 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -44,12 +44,12 @@ module ActionView
#
# +html_options+ may be a hash of attributes for the <tt>\<script></tt>
# tag. Example:
- # javascript_tag "alert('All is good')", :defer => 'defer'
+ # javascript_tag "alert('All is good')", defer: 'defer'
# # => <script defer="defer">alert('All is good')</script>
#
# Instead of passing the content as an argument, you can also use a block
# in which case, you pass your +html_options+ as the first parameter.
- # <%= javascript_tag :defer => 'defer' do -%>
+ # <%= javascript_tag defer: 'defer' do -%>
# alert('All is good')
# <% end -%>
def javascript_tag(content_or_options_with_block = nil, html_options = {}, &block)
@@ -74,7 +74,7 @@ module ActionView
# name is used as button label and the JavaScript code goes into its +onclick+ attribute.
# If +html_options+ has an <tt>:onclick</tt>, that one is put before +function+.
#
- # button_to_function "Greeting", "alert('Hello world!')", :class => "ok"
+ # button_to_function "Greeting", "alert('Hello world!')", class: "ok"
# # => <input class="ok" onclick="alert('Hello world!');" type="button" value="Greeting" />
#
def button_to_function(name, function=nil, html_options={})
@@ -96,7 +96,7 @@ module ActionView
#
# The +href+ attribute of the tag is set to "#" unless +html_options+ has one.
#
- # link_to_function "Greeting", "alert('Hello world!')", :class => "nav_link"
+ # link_to_function "Greeting", "alert('Hello world!')", class: "nav_link"
# # => <a class="nav_link" href="#" onclick="alert('Hello world!'); return false;">Greeting</a>
#
def link_to_function(name, function, html_options={})
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb
index 9720e90429..82340171af 100644
--- a/actionpack/lib/action_view/helpers/number_helper.rb
+++ b/actionpack/lib/action_view/helpers/number_helper.rb
@@ -45,15 +45,15 @@ module ActionView
# number_to_phone(5551234) # => 555-1234
# number_to_phone("5551234") # => 555-1234
# number_to_phone(1235551234) # => 123-555-1234
- # number_to_phone(1235551234, :area_code => true) # => (123) 555-1234
- # number_to_phone(1235551234, :delimiter => " ") # => 123 555 1234
- # number_to_phone(1235551234, :area_code => true, :extension => 555) # => (123) 555-1234 x 555
- # number_to_phone(1235551234, :country_code => 1) # => +1-123-555-1234
+ # number_to_phone(1235551234, area_code: true) # => (123) 555-1234
+ # number_to_phone(1235551234, delimiter: " ") # => 123 555 1234
+ # number_to_phone(1235551234, area_code: true, extension: 555) # => (123) 555-1234 x 555
+ # number_to_phone(1235551234, country_code: 1) # => +1-123-555-1234
# number_to_phone("123a456") # => 123a456
#
- # number_to_phone("1234a567", :raise => true) # => InvalidNumberError
+ # number_to_phone("1234a567", raise: true) # => InvalidNumberError
#
- # number_to_phone(1235551234, :country_code => 1, :extension => 1343, :delimiter => ".")
+ # number_to_phone(1235551234, country_code: 1, extension: 1343, delimiter: ".")
# # => +1.123.555.1234 x 1343
def number_to_phone(number, options = {})
return unless number
@@ -93,17 +93,17 @@ module ActionView
#
# number_to_currency(1234567890.50) # => $1,234,567,890.50
# number_to_currency(1234567890.506) # => $1,234,567,890.51
- # number_to_currency(1234567890.506, :precision => 3) # => $1,234,567,890.506
- # number_to_currency(1234567890.506, :locale => :fr) # => 1 234 567 890,51 €
+ # number_to_currency(1234567890.506, precision: 3) # => $1,234,567,890.506
+ # number_to_currency(1234567890.506, locale: :fr) # => 1 234 567 890,51 €
# number_to_currency("123a456") # => $123a456
#
- # number_to_currency("123a456", :raise => true) # => InvalidNumberError
+ # number_to_currency("123a456", raise: true) # => InvalidNumberError
#
- # number_to_currency(-1234567890.50, :negative_format => "(%u%n)")
+ # number_to_currency(-1234567890.50, negative_format: "(%u%n)")
# # => ($1,234,567,890.50)
- # number_to_currency(1234567890.50, :unit => "&pound;", :separator => ",", :delimiter => "")
+ # number_to_currency(1234567890.50, unit: "&pound;", separator: ",", delimiter: "")
# # => &pound;1234567890,50
- # number_to_currency(1234567890.50, :unit => "&pound;", :separator => ",", :delimiter => "", :format => "%n %u")
+ # number_to_currency(1234567890.50, unit: "&pound;", separator: ",", delimiter: "", format: "%n %u")
# # => 1234567890,50 &pound;
def number_to_currency(number, options = {})
return unless number
@@ -142,14 +142,14 @@ module ActionView
#
# number_to_percentage(100) # => 100.000%
# number_to_percentage("98") # => 98.000%
- # number_to_percentage(100, :precision => 0) # => 100%
- # number_to_percentage(1000, :delimiter => '.', :separator => ',') # => 1.000,000%
- # number_to_percentage(302.24398923423, :precision => 5) # => 302.24399%
- # number_to_percentage(1000, :locale => :fr) # => 1 000,000%
+ # number_to_percentage(100, precision: 0) # => 100%
+ # number_to_percentage(1000, delimiter: '.', separator: ',') # => 1.000,000%
+ # number_to_percentage(302.24398923423, precision: 5) # => 302.24399%
+ # number_to_percentage(1000, locale: :fr) # => 1 000,000%
# number_to_percentage("98a") # => 98a%
- # number_to_percentage(100, :format => "%n %") # => 100 %
+ # number_to_percentage(100, format: "%n %") # => 100 %
#
- # number_to_percentage("98a", :raise => true) # => InvalidNumberError
+ # number_to_percentage("98a", raise: true) # => InvalidNumberError
def number_to_percentage(number, options = {})
return unless number
options = escape_unsafe_delimiters_and_separators(options.symbolize_keys)
@@ -179,15 +179,15 @@ module ActionView
# number_with_delimiter(12345678) # => 12,345,678
# number_with_delimiter("123456") # => 123,456
# number_with_delimiter(12345678.05) # => 12,345,678.05
- # number_with_delimiter(12345678, :delimiter => ".") # => 12.345.678
- # number_with_delimiter(12345678, :delimiter => ",") # => 12,345,678
- # number_with_delimiter(12345678.05, :separator => " ") # => 12,345,678 05
- # number_with_delimiter(12345678.05, :locale => :fr) # => 12 345 678,05
+ # number_with_delimiter(12345678, delimiter: ".") # => 12.345.678
+ # number_with_delimiter(12345678, delimiter: ",") # => 12,345,678
+ # number_with_delimiter(12345678.05, separator: " ") # => 12,345,678 05
+ # number_with_delimiter(12345678.05, locale: :fr) # => 12 345 678,05
# number_with_delimiter("112a") # => 112a
- # number_with_delimiter(98765432.98, :delimiter => " ", :separator => ",")
+ # number_with_delimiter(98765432.98, delimiter: " ", separator: ",")
# # => 98 765 432,98
#
- # number_with_delimiter("112a", :raise => true) # => raise InvalidNumberError
+ # number_with_delimiter("112a", raise: true) # => raise InvalidNumberError
def number_with_delimiter(number, options = {})
options = escape_unsafe_delimiters_and_separators(options.symbolize_keys)
@@ -223,19 +223,19 @@ module ActionView
# ==== Examples
#
# number_with_precision(111.2345) # => 111.235
- # number_with_precision(111.2345, :precision => 2) # => 111.23
- # number_with_precision(13, :precision => 5) # => 13.00000
- # number_with_precision(389.32314, :precision => 0) # => 389
- # number_with_precision(111.2345, :significant => true) # => 111
- # number_with_precision(111.2345, :precision => 1, :significant => true) # => 100
- # number_with_precision(13, :precision => 5, :significant => true) # => 13.000
- # number_with_precision(111.234, :locale => :fr) # => 111,234
- #
- # number_with_precision(13, :precision => 5, :significant => true, :strip_insignificant_zeros => true)
+ # number_with_precision(111.2345, precision: 2) # => 111.23
+ # number_with_precision(13, precision: 5) # => 13.00000
+ # number_with_precision(389.32314, precision: 0) # => 389
+ # number_with_precision(111.2345, significant: true) # => 111
+ # number_with_precision(111.2345, precision: 1, significant: true) # => 100
+ # number_with_precision(13, precision: 5, significant: true) # => 13.000
+ # number_with_precision(111.234, locale: :fr) # => 111,234
+ #
+ # number_with_precision(13, precision: 5, significant: true, strip_insignificant_zeros: true)
# # => 13
#
- # number_with_precision(389.32314, :precision => 4, :significant => true) # => 389.3
- # number_with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.')
+ # number_with_precision(389.32314, precision: 4, significant: true) # => 389.3
+ # number_with_precision(1111.2345, precision: 2, separator: ',', delimiter: '.')
# # => 1.111,23
def number_with_precision(number, options = {})
options = escape_unsafe_delimiters_and_separators(options.symbolize_keys)
@@ -283,16 +283,16 @@ module ActionView
# number_to_human_size(1234567) # => 1.18 MB
# number_to_human_size(1234567890) # => 1.15 GB
# number_to_human_size(1234567890123) # => 1.12 TB
- # number_to_human_size(1234567, :precision => 2) # => 1.2 MB
- # number_to_human_size(483989, :precision => 2) # => 470 KB
- # number_to_human_size(1234567, :precision => 2, :separator => ',') # => 1,2 MB
+ # number_to_human_size(1234567, precision: 2) # => 1.2 MB
+ # number_to_human_size(483989, precision: 2) # => 470 KB
+ # number_to_human_size(1234567, precision: 2, separator: ',') # => 1,2 MB
#
# Non-significant zeros after the fractional separator are
# stripped out by default (set
# <tt>:strip_insignificant_zeros</tt> to +false+ to change
# that):
- # number_to_human_size(1234567890123, :precision => 5) # => "1.1229 TB"
- # number_to_human_size(524288000, :precision => 5) # => "500 MB"
+ # number_to_human_size(1234567890123, precision: 5) # => "1.1229 TB"
+ # number_to_human_size(524288000, precision: 5) # => "500 MB"
def number_to_human_size(number, options = {})
options = escape_unsafe_delimiters_and_separators(options.symbolize_keys)
@@ -358,24 +358,24 @@ module ActionView
# number_to_human(1234567890123) # => "1.23 Trillion"
# number_to_human(1234567890123456) # => "1.23 Quadrillion"
# number_to_human(1234567890123456789) # => "1230 Quadrillion"
- # number_to_human(489939, :precision => 2) # => "490 Thousand"
- # number_to_human(489939, :precision => 4) # => "489.9 Thousand"
- # number_to_human(1234567, :precision => 4,
- # :significant => false) # => "1.2346 Million"
- # number_to_human(1234567, :precision => 1,
- # :separator => ',',
- # :significant => false) # => "1,2 Million"
+ # number_to_human(489939, precision: 2) # => "490 Thousand"
+ # number_to_human(489939, precision: 4) # => "489.9 Thousand"
+ # number_to_human(1234567, precision: 4,
+ # significant: false) # => "1.2346 Million"
+ # number_to_human(1234567, precision: 1,
+ # separator: ',',
+ # significant: false) # => "1,2 Million"
#
# Non-significant zeros after the decimal separator are stripped
# out by default (set <tt>:strip_insignificant_zeros</tt> to
# +false+ to change that):
- # number_to_human(12345012345, :significant_digits => 6) # => "12.345 Billion"
- # number_to_human(500000000, :precision => 5) # => "500 Million"
+ # number_to_human(12345012345, significant_digits: 6) # => "12.345 Billion"
+ # number_to_human(500000000, precision: 5) # => "500 Million"
#
# ==== Custom Unit Quantifiers
#
# You can also use your own custom unit quantifiers:
- # number_to_human(500000, :units => {:unit => "ml", :thousand => "lt"}) # => "500 lt"
+ # number_to_human(500000, units: {unit: "ml", thousand: "lt"}) # => "500 lt"
#
# If in your I18n locale you have:
# distance:
@@ -392,12 +392,12 @@ module ActionView
#
# Then you could do:
#
- # number_to_human(543934, :units => :distance) # => "544 kilometers"
- # number_to_human(54393498, :units => :distance) # => "54400 kilometers"
- # number_to_human(54393498000, :units => :distance) # => "54.4 gazillion-distance"
- # number_to_human(343, :units => :distance, :precision => 1) # => "300 meters"
- # number_to_human(1, :units => :distance) # => "1 meter"
- # number_to_human(0.34, :units => :distance) # => "34 centimeters"
+ # number_to_human(543934, units: :distance) # => "544 kilometers"
+ # number_to_human(54393498, units: :distance) # => "54400 kilometers"
+ # number_to_human(54393498000, units: :distance) # => "54.4 gazillion-distance"
+ # number_to_human(343, units: :distance, precision: 1) # => "300 meters"
+ # number_to_human(1, units: :distance) # => "1 meter"
+ # number_to_human(0.34, units: :distance) # => "34 centimeters"
#
def number_to_human(number, options = {})
options = escape_unsafe_delimiters_and_separators(options.symbolize_keys)
diff --git a/actionpack/lib/action_view/helpers/record_tag_helper.rb b/actionpack/lib/action_view/helpers/record_tag_helper.rb
index dded9aab7c..33194250b7 100644
--- a/actionpack/lib/action_view/helpers/record_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/record_tag_helper.rb
@@ -7,7 +7,7 @@ module ActionView
# Produces a wrapper DIV element with id and class parameters that
# relate to the specified Active Record object. Usage example:
#
- # <%= div_for(@person, :class => "foo") do %>
+ # <%= div_for(@person, class: "foo") do %>
# <%= @person.name %>
# <% end %>
#
@@ -19,7 +19,7 @@ module ActionView
# get iterated over and yield each record as an argument for the block.
# For example:
#
- # <%= div_for(@people, :class => "foo") do |person| %>
+ # <%= div_for(@people, class: "foo") do |person| %>
# <%= person.name %>
# <% end %>
#
@@ -72,7 +72,7 @@ module ActionView
# additional HTML attributes. If you specify a <tt>:class</tt> value, it will be combined
# with the default class name for your object. For example:
#
- # <%= content_tag_for(:li, @person, :class => "bar") %>...
+ # <%= content_tag_for(:li, @person, class: "bar") %>...
#
# produces:
#
diff --git a/actionpack/lib/action_view/helpers/rendering_helper.rb b/actionpack/lib/action_view/helpers/rendering_helper.rb
index 626e1a1ab7..458086de96 100644
--- a/actionpack/lib/action_view/helpers/rendering_helper.rb
+++ b/actionpack/lib/action_view/helpers/rendering_helper.rb
@@ -39,7 +39,7 @@ module ActionView
# The user can override this default by passing a block to the layout:
#
# # The template
- # <%= render :layout => "my_layout" do %>
+ # <%= render layout: "my_layout" do %>
# Content
# <% end %>
#
@@ -59,7 +59,7 @@ module ActionView
# Finally, the block can take block arguments, which can be passed in by +yield+:
#
# # The template
- # <%= render :layout => "my_layout" do |customer| %>
+ # <%= render layout: "my_layout" do |customer| %>
# Hello <%= customer.name %>
# <% end %>
#
diff --git a/actionpack/lib/action_view/helpers/sanitize_helper.rb b/actionpack/lib/action_view/helpers/sanitize_helper.rb
index 9c76c26ace..e6f61d269c 100644
--- a/actionpack/lib/action_view/helpers/sanitize_helper.rb
+++ b/actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -29,7 +29,7 @@ module ActionView
#
# Custom Use (only the mentioned tags and attributes are allowed, nothing else)
#
- # <%= sanitize @article.body, :tags => %w(table tr td), :attributes => %w(id class style) %>
+ # <%= sanitize @article.body, tags: %w(table tr td), attributes: %w(id class style) %>
#
# Add table tags to the default allowed tags
#
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index 3327c69d61..8c7524e795 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -50,16 +50,16 @@ module ActionView
# tag("br", nil, true)
# # => <br>
#
- # tag("input", :type => 'text', :disabled => true)
+ # tag("input", type: 'text', disabled: true)
# # => <input type="text" disabled="disabled" />
#
- # tag("img", :src => "open & shut.png")
+ # tag("img", src: "open & shut.png")
# # => <img src="open &amp; shut.png" />
#
- # tag("img", {:src => "open &amp; shut.png"}, false, false)
+ # tag("img", {src: "open &amp; shut.png"}, false, false)
# # => <img src="open &amp; shut.png" />
#
- # tag("div", :data => {:name => 'Stephen', :city_state => %w(Chicago IL)})
+ # tag("div", data: {name: 'Stephen', city_state: %w(Chicago IL)})
# # => <div data-name="Stephen" data-city-state="[&quot;Chicago&quot;,&quot;IL&quot;]" />
def tag(name, options = nil, open = false, escape = true)
"<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe
@@ -79,12 +79,12 @@ module ActionView
# ==== Examples
# content_tag(:p, "Hello world!")
# # => <p>Hello world!</p>
- # content_tag(:div, content_tag(:p, "Hello world!"), :class => "strong")
+ # content_tag(:div, content_tag(:p, "Hello world!"), class: "strong")
# # => <div class="strong"><p>Hello world!</p></div>
- # content_tag("select", options, :multiple => true)
+ # content_tag("select", options, multiple: true)
# # => <select multiple="multiple">...options...</select>
#
- # <%= content_tag :div, :class => "strong" do -%>
+ # <%= content_tag :div, class: "strong" do -%>
# Hello world!
# <% end -%>
# # => <div class="strong">Hello world!</div>
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 527bfe0cab..26d2142df9 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -43,7 +43,7 @@ module ActionView
# if logged_in
# concat "Logged in!"
# else
- # concat link_to('login', :action => :login)
+ # concat link_to('login', action: :login)
# end
# # will either display "Logged in!" or a login link
# %>
@@ -70,13 +70,13 @@ module ActionView
# truncate("Once upon a time in a world far far away")
# # => "Once upon a time in a world..."
#
- # truncate("Once upon a time in a world far far away", :length => 17)
+ # truncate("Once upon a time in a world far far away", length: 17)
# # => "Once upon a ti..."
#
- # truncate("Once upon a time in a world far far away", :length => 17, :separator => ' ')
+ # truncate("Once upon a time in a world far far away", length: 17, separator: ' ')
# # => "Once upon a..."
#
- # truncate("And they found that many people were sleeping better.", :length => 25, :omission => '... (continued)')
+ # truncate("And they found that many people were sleeping better.", length: 25, omission: '... (continued)')
# # => "And they f... (continued)"
#
# truncate("<p>Once upon a time in a world far far away</p>")
@@ -106,10 +106,10 @@ module ActionView
# highlight('You searched for: ruby, rails, dhh', 'actionpack')
# # => You searched for: ruby, rails, dhh
#
- # highlight('You searched for: rails', ['for', 'rails'], :highlighter => '<em>\1</em>')
+ # highlight('You searched for: rails', ['for', 'rails'], highlighter: '<em>\1</em>')
# # => You searched <em>for</em>: <em>rails</em>
#
- # highlight('You searched for: rails', 'rails', :highlighter => '<a href="search?q=\1">\1</a>')
+ # highlight('You searched for: rails', 'rails', highlighter: '<a href="search?q=\1">\1</a>')
# # => You searched for: <a href="search?q=rails">rails</a>
def highlight(text, phrases, options = {})
highlighter = options.fetch(:highlighter, '<mark>\1</mark>')
@@ -130,22 +130,22 @@ module ActionView
# <tt>:separator</tt> enable to choose the delimation. The resulting string will be stripped in any case. If the +phrase+
# isn't found, nil is returned.
#
- # excerpt('This is an example', 'an', :radius => 5)
+ # excerpt('This is an example', 'an', radius: 5)
# # => ...s is an exam...
#
- # excerpt('This is an example', 'is', :radius => 5)
+ # excerpt('This is an example', 'is', radius: 5)
# # => This is a...
#
# excerpt('This is an example', 'is')
# # => This is an example
#
- # excerpt('This next thing is an example', 'ex', :radius => 2)
+ # excerpt('This next thing is an example', 'ex', radius: 2)
# # => ...next...
#
- # excerpt('This is also an example', 'an', :radius => 8, :omission => '<chop> ')
+ # excerpt('This is also an example', 'an', radius: 8, omission: '<chop> ')
# # => <chop> is also an example
#
- # excerpt('This is a very beautiful morning', 'very', :separator => ' ', :radius => 1)
+ # excerpt('This is a very beautiful morning', 'very', separator: ' ', radius: 1)
# # => ...a very beautiful...
def excerpt(text, phrase, options = {})
return unless text && phrase
@@ -207,10 +207,10 @@ module ActionView
# word_wrap('Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding a successor to the throne turned out to be more trouble than anyone could have imagined...')
# # => Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding\na successor to the throne turned out to be more trouble than anyone could have\nimagined...
#
- # word_wrap('Once upon a time', :line_width => 8)
+ # word_wrap('Once upon a time', line_width: 8)
# # => Once\nupon a\ntime
#
- # word_wrap('Once upon a time', :line_width => 1)
+ # word_wrap('Once upon a time', line_width: 1)
# # => Once\nupon\na\ntime
def word_wrap(text, options = {})
line_width = options.fetch(:line_width, 80)
@@ -239,7 +239,7 @@ module ActionView
# simple_format(my_text)
# # => "<p>Here is some basic text...\n<br />...with a line break.</p>"
#
- # simple_format(my_text, {}, :wrapper_tag => "div")
+ # simple_format(my_text, {}, wrapper_tag: "div")
# # => "<div>Here is some basic text...\n<br />...with a line break.</div>"
#
# more_text = "We want to put a paragraph...\n\n...right there."
@@ -247,10 +247,10 @@ module ActionView
# simple_format(more_text)
# # => "<p>We want to put a paragraph...</p>\n\n<p>...right there.</p>"
#
- # simple_format("Look ma! A class!", :class => 'description')
+ # simple_format("Look ma! A class!", class: 'description')
# # => "<p class='description'>Look ma! A class!</p>"
#
- # simple_format("<span>I'm allowed!</span> It's true.", {}, :sanitize => false)
+ # simple_format("<span>I'm allowed!</span> It's true.", {}, sanitize: false)
# # => "<p><span>I'm allowed!</span> It's true.</p>"
def simple_format(text, html_options = {}, options = {})
wrapper_tag = options.fetch(:wrapper_tag, :p)
@@ -288,15 +288,15 @@ module ActionView
#
#
# # Cycle CSS classes for rows, and text colors for values within each row
- # @items = x = [{:first => 'Robert', :middle => 'Daniel', :last => 'James'},
- # {:first => 'Emily', :middle => 'Shannon', :maiden => 'Pike', :last => 'Hicks'},
- # {:first => 'June', :middle => 'Dae', :last => 'Jones'}]
+ # @items = x = [{first: 'Robert', middle: 'Daniel', last: 'James'},
+ # {first: 'Emily', middle: 'Shannon', maiden: 'Pike', last: 'Hicks'},
+ # {first: 'June', middle: 'Dae', last: 'Jones'}]
# <% @items.each do |item| %>
- # <tr class="<%= cycle("odd", "even", :name => "row_class") -%>">
+ # <tr class="<%= cycle("odd", "even", name: "row_class") -%>">
# <td>
# <% item.values.each do |value| %>
# <%# Create a named cycle "colors" %>
- # <span style="color:<%= cycle("red", "green", "blue", :name => "colors") -%>">
+ # <span style="color:<%= cycle("red", "green", "blue", name: "colors") -%>">
# <%= value %>
# </span>
# <% end %>
@@ -342,7 +342,7 @@ module ActionView
# <% @items.each do |item| %>
# <tr class="<%= cycle("even", "odd") -%>">
# <% item.each do |value| %>
- # <span style="color:<%= cycle("#333", "#666", "#999", :name => "colors") -%>">
+ # <span style="color:<%= cycle("#333", "#666", "#999", name: "colors") -%>">
# <%= value %>
# </span>
# <% end %>
diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb
index 552c9ba660..ad8eb47f1f 100644
--- a/actionpack/lib/action_view/helpers/translation_helper.rb
+++ b/actionpack/lib/action_view/helpers/translation_helper.rb
@@ -17,7 +17,7 @@ module ActionView
module TranslationHelper
# Delegates to <tt>I18n#translate</tt> but also performs three additional functions.
#
- # First, it'll pass the <tt>:rescue_format => :html</tt> option to I18n so that any
+ # First, it'll pass the <tt>rescue_format: :html</tt> option to I18n so that any
# thrown +MissingTranslation+ messages will be turned into inline spans that
#
# * have a "translation-missing" class set,
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 48ac4312b6..fd671c9c07 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -73,17 +73,17 @@ module ActionView
#
# ==== Options
# * <tt>:data</tt> - This option can be used to add custom data attributes.
- # * <tt>:method => symbol of HTTP verb</tt> - This modifier will dynamically
+ # * <tt>method: symbol of HTTP verb</tt> - This modifier will dynamically
# create an HTML form and immediately submit the form for processing using
# the HTTP verb specified. Useful for having links perform a POST operation
# in dangerous actions like deleting a record (which search bots can follow
# while spidering your site). Supported verbs are <tt>:post</tt>, <tt>:delete</tt>, <tt>:patch</tt>, and <tt>:put</tt>.
# Note that if the user has JavaScript disabled, the request will fall back
- # to using GET. If <tt>:href => '#'</tt> is used and the user has JavaScript
+ # to using GET. If <tt>href: '#'</tt> is used and the user has JavaScript
# disabled clicking the link will have no effect. If you are relying on the
# POST behavior, you should check for it in your controller's action by using
# the request object's methods for <tt>post?</tt>, <tt>delete?</tt>, <tt>:patch</tt>, or <tt>put?</tt>.
- # * <tt>:remote => true</tt> - This will allow the unobtrusive JavaScript
+ # * <tt>remote: true</tt> - This will allow the unobtrusive JavaScript
# driver to make an Ajax request to the URL in question instead of following
# the link. The drivers each provide mechanisms for listening for the
# completion of the Ajax request and performing JavaScript operations once
@@ -91,7 +91,7 @@ module ActionView
#
# ==== Data attributes
#
- # * <tt>:confirm => 'question?'</tt> - This will allow the unobtrusive JavaScript
+ # * <tt>confirm: 'question?'</tt> - This will allow the unobtrusive JavaScript
# driver to prompt with the question specified. If the user accepts, the link is
# processed normally, otherwise no action is taken.
# * <tt>:disable_with</tt> - Value of this parameter will be
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb
index edefeac184..36d557e1a3 100644
--- a/actionpack/lib/action_view/renderer/partial_renderer.rb
+++ b/actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -9,16 +9,16 @@ module ActionView
#
# In a template for Advertiser#account:
#
- # <%= render :partial => "account" %>
+ # <%= render partial: "account" %>
#
# This would render "advertiser/_account.html.erb".
#
# In another template for Advertiser#buy, we could have:
#
- # <%= render :partial => "account", :locals => { :account => @buyer } %>
+ # <%= render partial: "account", locals: { account: @buyer } %>
#
# <% @advertisements.each do |ad| %>
- # <%= render :partial => "ad", :locals => { :ad => ad } %>
+ # <%= render partial: "ad", locals: { ad: ad } %>
# <% end %>
#
# This would first render "advertiser/_account.html.erb" with @buyer passed in as the local variable +account+, then
@@ -29,21 +29,21 @@ module ActionView
# By default <tt>ActionView::PartialRenderer</tt> doesn't have any local variables.
# The <tt>:object</tt> option can be used to pass an object to the partial. For instance:
#
- # <%= render :partial => "account", :object => @buyer %>
+ # <%= render partial: "account", object: @buyer %>
#
# would provide the <tt>@buyer</tt> object to the partial, available under the local variable +account+ and is
# equivalent to:
#
- # <%= render :partial => "account", :locals => { :account => @buyer } %>
+ # <%= render partial: "account", locals: { account: @buyer } %>
#
# With the <tt>:as</tt> option we can specify a different name for said local variable. For example, if we
# wanted it to be +user+ instead of +account+ we'd do:
#
- # <%= render :partial => "account", :object => @buyer, :as => 'user' %>
+ # <%= render partial: "account", object: @buyer, as: 'user' %>
#
# This is equivalent to
#
- # <%= render :partial => "account", :locals => { :user => @buyer } %>
+ # <%= render partial: "account", locals: { user: @buyer } %>
#
# == Rendering a collection of partials
#
@@ -52,7 +52,7 @@ module ActionView
# accepts an array and renders a partial by the same name as the elements contained within. So the three-lined
# example in "Using partials" can be rewritten with a single line:
#
- # <%= render :partial => "ad", :collection => @advertisements %>
+ # <%= render partial: "ad", collection: @advertisements %>
#
# This will render "advertiser/_ad.html.erb" and pass the local variable +ad+ to the template for display. An
# iteration counter will automatically be made available to the template with a name of the form
@@ -63,12 +63,12 @@ module ActionView
# You can specify a partial to be rendered between elements via the <tt>:spacer_template</tt> option.
# The following example will render <tt>advertiser/_ad_divider.html.erb</tt> between each ad partial:
#
- # <%= render :partial => "ad", :collection => @advertisements, :spacer_template => "ad_divider" %>
+ # <%= render partial: "ad", collection: @advertisements, spacer_template: "ad_divider" %>
#
# If the given <tt>:collection</tt> is nil or empty, <tt>render</tt> will return nil. This will allow you
# to specify a text which will displayed instead by using this form:
#
- # <%= render(:partial => "ad", :collection => @advertisements) || "There's no ad to be displayed" %>
+ # <%= render(partial: "ad", collection: @advertisements) || "There's no ad to be displayed" %>
#
# NOTE: Due to backwards compatibility concerns, the collection can't be one of hashes. Normally you'd also
# just keep domain objects, like Active Records, in there.
@@ -77,7 +77,7 @@ module ActionView
#
# Two controllers can share a set of partials and render them like this:
#
- # <%= render :partial => "advertisement/ad", :locals => { :ad => @advertisement } %>
+ # <%= render partial: "advertisement/ad", locals: { ad: @advertisement } %>
#
# This will render the partial "advertisement/_ad.html.erb" regardless of which controller this is being called from.
#
@@ -87,32 +87,32 @@ module ActionView
# and pick the proper path by checking `to_partial_path` method.
#
# # @account.to_partial_path returns 'accounts/account', so it can be used to replace:
- # # <%= render :partial => "accounts/account", :locals => { :account => @account} %>
- # <%= render :partial => @account %>
+ # # <%= render partial: "accounts/account", locals: { account: @account} %>
+ # <%= render partial: @account %>
#
# # @posts is an array of Post instances, so every post record returns 'posts/post' on `to_partial_path`,
# # that's why we can replace:
- # # <%= render :partial => "posts/post", :collection => @posts %>
- # <%= render :partial => @posts %>
+ # # <%= render partial: "posts/post", collection: @posts %>
+ # <%= render partial: @posts %>
#
# == Rendering the default case
#
# If you're not going to be using any of the options like collections or layouts, you can also use the short-hand
# defaults of render to render partials. Examples:
#
- # # Instead of <%= render :partial => "account" %>
+ # # Instead of <%= render partial: "account" %>
# <%= render "account" %>
#
- # # Instead of <%= render :partial => "account", :locals => { :account => @buyer } %>
- # <%= render "account", :account => @buyer %>
+ # # Instead of <%= render partial: "account", locals: { account: @buyer } %>
+ # <%= render "account", account: @buyer %>
#
# # @account.to_partial_path returns 'accounts/account', so it can be used to replace:
- # # <%= render :partial => "accounts/account", :locals => { :account => @account} %>
+ # # <%= render partial: "accounts/account", locals: { account: @account} %>
# <%= render @account %>
#
# # @posts is an array of Post instances, so every post record returns 'posts/post' on `to_partial_path`,
# # that's why we can replace:
- # # <%= render :partial => "posts/post", :collection => @posts %>
+ # # <%= render partial: "posts/post", collection: @posts %>
# <%= render @posts %>
#
# == Rendering partials with layouts
@@ -123,10 +123,10 @@ module ActionView
#
# <%# app/views/users/index.html.erb &>
# Here's the administrator:
- # <%= render :partial => "user", :layout => "administrator", :locals => { :user => administrator } %>
+ # <%= render partial: "user", layout: "administrator", locals: { user: administrator } %>
#
# Here's the editor:
- # <%= render :partial => "user", :layout => "editor", :locals => { :user => editor } %>
+ # <%= render partial: "user", layout: "editor", locals: { user: editor } %>
#
# <%# app/views/users/_user.html.erb &>
# Name: <%= user.name %>
@@ -168,7 +168,7 @@ module ActionView
# <ul>
# <% users.each do |user| -%>
# <li>
- # <%= render :partial => "user", :locals => { :user => user } %>
+ # <%= render partial: "user", locals: { user: user } %>
# </li>
# <% end -%>
# </ul>
@@ -180,7 +180,7 @@ module ActionView
#
# <%# app/views/users/index.html.erb %>
# <ul>
- # <%= render :partial => "user", :layout => "li_layout", :collection => users %>
+ # <%= render partial: "user", layout: "li_layout", collection: users %>
# </ul>
#
# Given two users whose names are Alice and Bob, these snippets return:
@@ -201,7 +201,7 @@ module ActionView
# You can also apply a layout to a block within any template:
#
# <%# app/views/users/_chief.html.erb &>
- # <%= render(:layout => "administrator", :locals => { :user => chief }) do %>
+ # <%= render(layout: "administrator", locals: { user: chief }) do %>
# Title: <%= chief.title %>
# <% end %>
#
@@ -224,7 +224,7 @@ module ActionView
# </div>
#
# <%# app/views/users/index.html.erb &>
- # <%= render :layout => @users do |user| %>
+ # <%= render layout: @users do |user| %>
# Title: <%= user.title %>
# <% end %>
#
@@ -240,7 +240,7 @@ module ActionView
# </div>
#
# <%# app/views/users/index.html.erb &>
- # <%= render :layout => @users do |user, section| %>
+ # <%= render layout: @users do |user, section| %>
# <%- case section when :header -%>
# Title: <%= user.title %>
# <%- when :footer -%>
diff --git a/actionpack/lib/action_view/routing_url_for.rb b/actionpack/lib/action_view/routing_url_for.rb
index d1488e2332..f10e7e88ba 100644
--- a/actionpack/lib/action_view/routing_url_for.rb
+++ b/actionpack/lib/action_view/routing_url_for.rb
@@ -29,19 +29,19 @@ module ActionView
# Controllers passed in using the +:controller+ option will retain their namespace unless it is an absolute one.
#
# ==== Examples
- # <%= url_for(:action => 'index') %>
+ # <%= url_for(action: 'index') %>
# # => /blog/
#
- # <%= url_for(:action => 'find', :controller => 'books') %>
+ # <%= url_for(action: 'find', controller: 'books') %>
# # => /books/find
#
- # <%= url_for(:action => 'login', :controller => 'members', :only_path => false, :protocol => 'https') %>
+ # <%= url_for(action: 'login', controller: 'members', only_path: false, protocol: 'https') %>
# # => https://www.example.com/members/login/
#
- # <%= url_for(:action => 'play', :anchor => 'player') %>
+ # <%= url_for(action: 'play', anchor: 'player') %>
# # => /messages/play/#player
#
- # <%= url_for(:action => 'jump', :anchor => 'tax&ship') %>
+ # <%= url_for(action: 'jump', anchor: 'tax&ship') %>
# # => /testing/jump/#tax&ship
#
# <%= url_for(Workshop.new) %>
@@ -66,11 +66,11 @@ module ActionView
# # if request.env["HTTP_REFERER"] is not set or is blank
# # => javascript:history.back()
#
- # <%= url_for(:action => 'index', :controller => 'users') %>
+ # <%= url_for(action: 'index', controller: 'users') %>
# # Assuming an "admin" namespace
# # => /admin/users
#
- # <%= url_for(:action => 'index', :controller => '/users') %>
+ # <%= url_for(action: 'index', controller: '/users') %>
# # Specify absolute path with beginning slash
# # => /users
def url_for(options = nil)
diff --git a/actionpack/lib/action_view/vendor/html-scanner/html/node.rb b/actionpack/lib/action_view/vendor/html-scanner/html/node.rb
index 4e1f016431..7e7cd4f7b6 100644
--- a/actionpack/lib/action_view/vendor/html-scanner/html/node.rb
+++ b/actionpack/lib/action_view/vendor/html-scanner/html/node.rb
@@ -383,32 +383,32 @@ module HTML #:nodoc:
# Usage:
#
# # test if the node is a "span" tag
- # node.match :tag => "span"
+ # node.match tag: "span"
#
# # test if the node's parent is a "div"
- # node.match :parent => { :tag => "div" }
+ # node.match parent: { tag: "div" }
#
# # test if any of the node's ancestors are "table" tags
- # node.match :ancestor => { :tag => "table" }
+ # node.match ancestor: { tag: "table" }
#
# # test if any of the node's immediate children are "em" tags
- # node.match :child => { :tag => "em" }
+ # node.match child: { tag: "em" }
#
# # test if any of the node's descendants are "strong" tags
- # node.match :descendant => { :tag => "strong" }
+ # node.match descendant: { tag: "strong" }
#
# # test if the node has between 2 and 4 span tags as immediate children
- # node.match :children => { :count => 2..4, :only => { :tag => "span" } }
+ # node.match children: { count: 2..4, only: { tag: "span" } }
#
# # get funky: test to see if the node is a "div", has a "ul" ancestor
# # and an "li" parent (with "class" = "enum"), and whether or not it has
# # a "span" descendant that contains # text matching /hello world/:
- # node.match :tag => "div",
- # :ancestor => { :tag => "ul" },
- # :parent => { :tag => "li",
- # :attributes => { :class => "enum" } },
- # :descendant => { :tag => "span",
- # :child => /hello world/ }
+ # node.match tag: "div",
+ # ancestor: { tag: "ul" },
+ # parent: { tag: "li",
+ # attributes: { class: "enum" } },
+ # descendant: { tag: "span",
+ # child: /hello world/ }
def match(conditions)
conditions = validate_conditions(conditions)
# check content of child nodes
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 6510629248..6882b59e26 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -75,14 +75,14 @@ module ActiveModel
@messages = {}
end
- def initialize_dup(other) #:nodoc:
+ def initialize_dup(other) # :nodoc:
@messages = other.messages.dup
super
end
# Clear the error messages.
#
- # person.errors.full_messages # => ["name can not be nil"]
+ # person.errors.full_messages # => ["name can not be nil"]
# person.errors.clear
# person.errors.full_messages # => []
def clear
@@ -92,9 +92,9 @@ module ActiveModel
# Returns +true+ if the error messages include an error for the given key
# +attribute+, +false+ otherwise.
#
- # person.errors.messages # => { :name => ["can not be nil"] }
+ # person.errors.messages # => {:name=>["can not be nil"]}
# person.errors.include?(:name) # => true
- # person.errors.include?(:age) # => false
+ # person.errors.include?(:age) # => false
def include?(attribute)
(v = messages[attribute]) && v.any?
end
@@ -103,7 +103,7 @@ module ActiveModel
# Get messages for +key+.
#
- # person.errors.messages # => { :name => ["can not be nil"] }
+ # person.errors.messages # => {:name=>["can not be nil"]}
# person.errors.get(:name) # => ["can not be nil"]
# person.errors.get(:age) # => nil
def get(key)
@@ -177,7 +177,7 @@ module ActiveModel
# Returns all message values.
#
- # person.errors.messages # => { :name => ["can not be nil", "must be specified"] }
+ # person.errors.messages # => {:name=>["can not be nil", "must be specified"]}
# person.errors.values # => [["can not be nil", "must be specified"]]
def values
messages.values
@@ -185,7 +185,7 @@ module ActiveModel
# Returns all message keys.
#
- # person.errors.messages # => { :name => ["can not be nil", "must be specified"] }
+ # person.errors.messages # => {:name=>["can not be nil", "must be specified"]}
# person.errors.keys # => [:name]
def keys
messages.keys
@@ -240,8 +240,8 @@ module ActiveModel
# object. You can pass the <tt>:full_messages</tt> option. This determines
# if the json object should contain full messages or not (false by default).
#
- # person.as_json # => { :name => ["can not be nil"] }
- # person.as_json(full_messages: true) # => { :name => ["name can not be nil"] }
+ # person.as_json # => {:name=>["can not be nil"]}
+ # person.as_json(full_messages: true) # => {:name=>["name can not be nil"]}
def as_json(options=nil)
to_hash(options && options[:full_messages])
end
@@ -249,8 +249,8 @@ module ActiveModel
# Returns a Hash of attributes with their error messages. If +full_messages+
# is +true+, it will contain full messages (see +full_message+).
#
- # person.to_hash # => { :name => ["can not be nil"] }
- # person.to_hash(true) # => { :name => ["name can not be nil"] }
+ # person.to_hash # => {:name=>["can not be nil"]}
+ # person.to_hash(true) # => {:name=>["name can not be nil"]}
def to_hash(full_messages = false)
if full_messages
messages = {}
@@ -273,7 +273,7 @@ module ActiveModel
# # => ["is invalid", "must be implemented"]
#
# person.errors.messages
- # # => { :name => ["must be implemented", "is invalid"] }
+ # # => {:name=>["must be implemented", "is invalid"]}
#
# If +message+ is a symbol, it will be translated using the appropriate
# scope (see +generate_message+).
@@ -286,9 +286,9 @@ module ActiveModel
# <tt>:strict</tt> option can also be set to any other exception.
#
# person.errors.add(:name, nil, strict: true)
- # # => ActiveModel::StrictValidationFailed: name is invalid
+ # # => ActiveModel::StrictValidationFailed: name is invalid
# person.errors.add(:name, nil, strict: NameIsInvalid)
- # # => NameIsInvalid: name is invalid
+ # # => NameIsInvalid: name is invalid
#
# person.errors.messages # => {}
def add(attribute, message = nil, options = {})
@@ -306,7 +306,7 @@ module ActiveModel
#
# person.errors.add_on_empty(:name)
# person.errors.messages
- # # => { :name => ["can't be empty"] }
+ # # => {:name=>["can't be empty"]}
def add_on_empty(attributes, options = {})
[attributes].flatten.each do |attribute|
value = @base.send(:read_attribute_for_validation, attribute)
@@ -320,7 +320,7 @@ module ActiveModel
#
# person.errors.add_on_blank(:name)
# person.errors.messages
- # # => { :name => ["can't be blank"] }
+ # # => {:name=>["can't be blank"]}
def add_on_blank(attributes, options = {})
[attributes].flatten.each do |attribute|
value = @base.send(:read_attribute_for_validation, attribute)
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 81b44f97e0..2524b8d065 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -33,7 +33,7 @@ module ActiveModel
# person.first_name = 'zoolander'
# person.valid? # => false
# person.invalid? # => true
- # person.errors.messages # => {:first_name=>["starts with z."]}
+ # person.errors.messages # => {first_name:["starts with z."]}
#
# Note that <tt>ActiveModel::Validations</tt> automatically adds an +errors+
# method to your instances initialized with a new <tt>ActiveModel::Errors</tt>
@@ -165,8 +165,8 @@ module ActiveModel
# Person.validators
# # => [
# # #<MyValidator:0x007fbff403e808 @options={}>,
- # # #<OtherValidator:0x007fbff403d930 @options={:on=>:create}>,
- # # #<StrictValidator:0x007fbff3204a30 @options={:strict=>true}>
+ # # #<OtherValidator:0x007fbff403d930 @options={on: :create}>,
+ # # #<StrictValidator:0x007fbff3204a30 @options={strict:true}>
# # ]
def validators
_validators.values.flatten.uniq
@@ -186,7 +186,7 @@ module ActiveModel
# Person.validators_on(:name)
# # => [
# # #<ActiveModel::Validations::PresenceValidator:0x007fe604914e60 @attributes=[:name], @options={}>,
- # # #<ActiveModel::Validations::InclusionValidator:0x007fe603bb8780 @attributes=[:age], @options={:in=>0..99}>
+ # # #<ActiveModel::Validations::InclusionValidator:0x007fe603bb8780 @attributes=[:age], @options={in:0..99}>
# # ]
def validators_on(*attributes)
attributes.flat_map do |attribute|
@@ -234,7 +234,7 @@ module ActiveModel
#
# person = Person.new
# person.valid? # => false
- # person.errors # => #<ActiveModel::Errors:0x007fe603816640 @messages={:name=>["can't be blank"]}>
+ # person.errors # => #<ActiveModel::Errors:0x007fe603816640 @messages={name:["can't be blank"]}>
def errors
@errors ||= Errors.new(self)
end
diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb
index ec7ad4b048..0935ad0d2a 100644
--- a/activemodel/lib/active_model/validations/acceptance.rb
+++ b/activemodel/lib/active_model/validations/acceptance.rb
@@ -1,8 +1,7 @@
module ActiveModel
- # == Active \Model Acceptance \Validator
module Validations
- class AcceptanceValidator < EachValidator #:nodoc:
+ class AcceptanceValidator < EachValidator # :nodoc:
def initialize(options)
super({ :allow_nil => true, :accept => "1" }.merge!(options))
end
@@ -27,7 +26,7 @@ module ActiveModel
#
# class Person < ActiveRecord::Base
# validates_acceptance_of :terms_of_service
- # validates_acceptance_of :eula, message: "must be abided"
+ # validates_acceptance_of :eula, message: 'must be abided'
# end
#
# If the database column does not exist, the +terms_of_service+ attribute
diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb
index 4071589747..3a3abce364 100644
--- a/activemodel/lib/active_model/validations/confirmation.rb
+++ b/activemodel/lib/active_model/validations/confirmation.rb
@@ -1,8 +1,7 @@
module ActiveModel
- # == Active \Model Confirmation \Validator
module Validations
- class ConfirmationValidator < EachValidator #:nodoc:
+ class ConfirmationValidator < EachValidator # :nodoc:
def validate_each(record, attribute, value)
if (confirmed = record.send("#{attribute}_confirmation")) && (value != confirmed)
human_attribute_name = record.class.human_attribute_name(attribute)
diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb
index 7a90750c49..b7f38e48f5 100644
--- a/activemodel/lib/active_model/validations/exclusion.rb
+++ b/activemodel/lib/active_model/validations/exclusion.rb
@@ -2,9 +2,8 @@ require "active_model/validations/clusivity"
module ActiveModel
- # == Active \Model Exclusion \Validator
module Validations
- class ExclusionValidator < EachValidator #:nodoc:
+ class ExclusionValidator < EachValidator # :nodoc:
include Clusivity
def validate_each(record, attribute, value)
diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb
index 80150229a0..9398b7e66e 100644
--- a/activemodel/lib/active_model/validations/format.rb
+++ b/activemodel/lib/active_model/validations/format.rb
@@ -1,8 +1,7 @@
module ActiveModel
- # == Active Model Format Validator
module Validations
- class FormatValidator < EachValidator #:nodoc:
+ class FormatValidator < EachValidator # :nodoc:
def validate_each(record, attribute, value)
if options[:with]
regexp = option_call(record, :with)
diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb
index a333a09976..5e45a04c2c 100644
--- a/activemodel/lib/active_model/validations/inclusion.rb
+++ b/activemodel/lib/active_model/validations/inclusion.rb
@@ -2,9 +2,8 @@ require "active_model/validations/clusivity"
module ActiveModel
- # == Active \Model Inclusion \Validator
module Validations
- class InclusionValidator < EachValidator #:nodoc:
+ class InclusionValidator < EachValidator # :nodoc:
include Clusivity
def validate_each(record, attribute, value)
diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb
index ffd045a8fb..744c196d30 100644
--- a/activemodel/lib/active_model/validations/numericality.rb
+++ b/activemodel/lib/active_model/validations/numericality.rb
@@ -1,6 +1,5 @@
module ActiveModel
- # == Active \Model Numericality \Validator
module Validations
class NumericalityValidator < EachValidator # :nodoc:
CHECKS = { :greater_than => :>, :greater_than_or_equal_to => :>=,
@@ -126,7 +125,7 @@ module ActiveModel
# For example:
#
# class Person < ActiveRecord::Base
- # validates_numericality_of :width, less_than: Proc.new { |person| person.height }
+ # validates_numericality_of :width, less_than: ->(person) { person.height }
# validates_numericality_of :width, greater_than: :minimum_weight
# end
def validates_numericality_of(*attr_names)
diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb
index 70247ee4c8..ae84c376b9 100644
--- a/activemodel/lib/active_model/validations/presence.rb
+++ b/activemodel/lib/active_model/validations/presence.rb
@@ -1,7 +1,6 @@
module ActiveModel
- # == Active \Model Presence \Validator
module Validations
class PresenceValidator < EachValidator # :nodoc:
def validate(record)
diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb
index 03046a543a..4651154934 100644
--- a/activemodel/lib/active_model/validations/validates.rb
+++ b/activemodel/lib/active_model/validations/validates.rb
@@ -1,7 +1,6 @@
require 'active_support/core_ext/hash/slice'
module ActiveModel
- # == Active Model validates method
module Validations
module ClassMethods
# This method is a shortcut to all default validators and any custom
@@ -129,15 +128,15 @@ module ActiveModel
# the validation itself.
#
# class Person
- #  include ActiveModel::Validations
+ # include ActiveModel::Validations
#
# attr_accessor :name
# validates! :name, presence: true
# end
#
# person = Person.new
- #  person.name = ''
- #  person.valid?
+ # person.name = ''
+ # person.valid?
# # => ActiveModel::StrictValidationFailed: Name can't be blank
def validates!(*attributes)
options = attributes.extract_options!
@@ -149,11 +148,11 @@ module ActiveModel
# When creating custom validators, it might be useful to be able to specify
# additional default keys. This can be done by overwriting this method.
- def _validates_default_keys #:nodoc:
+ def _validates_default_keys # :nodoc:
[:if, :unless, :on, :allow_blank, :allow_nil , :strict]
end
- def _parse_validates_options(options) #:nodoc:
+ def _parse_validates_options(options) # :nodoc:
case options
when TrueClass
{}
diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb
index 869591cd9e..2ae335d0f4 100644
--- a/activemodel/lib/active_model/validations/with.rb
+++ b/activemodel/lib/active_model/validations/with.rb
@@ -10,7 +10,7 @@ module ActiveModel
end
end
- class WithValidator < EachValidator #:nodoc:
+ class WithValidator < EachValidator # :nodoc:
def validate_each(record, attr, val)
method_name = options[:with]
diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb
index 09da4cc93d..c795dc9dcd 100644
--- a/activemodel/lib/active_model/validator.rb
+++ b/activemodel/lib/active_model/validator.rb
@@ -76,7 +76,7 @@ module ActiveModel
# include ActiveModel::Validations
# attr_accessor :title
#
- # validates :title, :presence => true
+ # validates :title, presence: true
# end
#
# Validator may also define a +setup+ instance method which will get called
diff --git a/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb b/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
index df0fcd243a..302cbe9761 100644
--- a/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
+++ b/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
@@ -8,7 +8,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
@person = Person.new
end
- # validates_inclusion_of: generate_message(attr_name, :inclusion, :message => custom_message, :value => value)
+ # validates_inclusion_of: generate_message(attr_name, :inclusion, message: custom_message, value: value)
def test_generate_message_inclusion_with_default_message
assert_equal 'is not included in the list', @person.errors.generate_message(:title, :inclusion, :value => 'title')
end
@@ -17,7 +17,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message title', @person.errors.generate_message(:title, :inclusion, :message => 'custom message %{value}', :value => 'title')
end
- # validates_exclusion_of: generate_message(attr_name, :exclusion, :message => custom_message, :value => value)
+ # validates_exclusion_of: generate_message(attr_name, :exclusion, message: custom_message, value: value)
def test_generate_message_exclusion_with_default_message
assert_equal 'is reserved', @person.errors.generate_message(:title, :exclusion, :value => 'title')
end
@@ -26,7 +26,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message title', @person.errors.generate_message(:title, :exclusion, :message => 'custom message %{value}', :value => 'title')
end
- # validates_format_of: generate_message(attr_name, :invalid, :message => custom_message, :value => value)
+ # validates_format_of: generate_message(attr_name, :invalid, message: custom_message, value: value)
def test_generate_message_invalid_with_default_message
assert_equal 'is invalid', @person.errors.generate_message(:title, :invalid, :value => 'title')
end
@@ -35,7 +35,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message title', @person.errors.generate_message(:title, :invalid, :message => 'custom message %{value}', :value => 'title')
end
- # validates_confirmation_of: generate_message(attr_name, :confirmation, :message => custom_message)
+ # validates_confirmation_of: generate_message(attr_name, :confirmation, message: custom_message)
def test_generate_message_confirmation_with_default_message
assert_equal "doesn't match Title", @person.errors.generate_message(:title, :confirmation)
end
@@ -44,7 +44,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message', @person.errors.generate_message(:title, :confirmation, :message => 'custom message')
end
- # validates_acceptance_of: generate_message(attr_name, :accepted, :message => custom_message)
+ # validates_acceptance_of: generate_message(attr_name, :accepted, message: custom_message)
def test_generate_message_accepted_with_default_message
assert_equal "must be accepted", @person.errors.generate_message(:title, :accepted)
end
@@ -53,7 +53,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message', @person.errors.generate_message(:title, :accepted, :message => 'custom message')
end
- # add_on_empty: generate_message(attr, :empty, :message => custom_message)
+ # add_on_empty: generate_message(attr, :empty, message: custom_message)
def test_generate_message_empty_with_default_message
assert_equal "can't be empty", @person.errors.generate_message(:title, :empty)
end
@@ -62,7 +62,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message', @person.errors.generate_message(:title, :empty, :message => 'custom message')
end
- # add_on_blank: generate_message(attr, :blank, :message => custom_message)
+ # add_on_blank: generate_message(attr, :blank, message: custom_message)
def test_generate_message_blank_with_default_message
assert_equal "can't be blank", @person.errors.generate_message(:title, :blank)
end
@@ -71,7 +71,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message', @person.errors.generate_message(:title, :blank, :message => 'custom message')
end
- # validates_length_of: generate_message(attr, :too_long, :message => custom_message, :count => option_value.end)
+ # validates_length_of: generate_message(attr, :too_long, message: custom_message, count: option_value.end)
def test_generate_message_too_long_with_default_message
assert_equal "is too long (maximum is 10 characters)", @person.errors.generate_message(:title, :too_long, :count => 10)
end
@@ -80,7 +80,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message 10', @person.errors.generate_message(:title, :too_long, :message => 'custom message %{count}', :count => 10)
end
- # validates_length_of: generate_message(attr, :too_short, :default => custom_message, :count => option_value.begin)
+ # validates_length_of: generate_message(attr, :too_short, default: custom_message, count: option_value.begin)
def test_generate_message_too_short_with_default_message
assert_equal "is too short (minimum is 10 characters)", @person.errors.generate_message(:title, :too_short, :count => 10)
end
@@ -89,7 +89,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message 10', @person.errors.generate_message(:title, :too_short, :message => 'custom message %{count}', :count => 10)
end
- # validates_length_of: generate_message(attr, :wrong_length, :message => custom_message, :count => option_value)
+ # validates_length_of: generate_message(attr, :wrong_length, message: custom_message, count: option_value)
def test_generate_message_wrong_length_with_default_message
assert_equal "is the wrong length (should be 10 characters)", @person.errors.generate_message(:title, :wrong_length, :count => 10)
end
@@ -98,7 +98,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message 10', @person.errors.generate_message(:title, :wrong_length, :message => 'custom message %{count}', :count => 10)
end
- # validates_numericality_of: generate_message(attr_name, :not_a_number, :value => raw_value, :message => custom_message)
+ # validates_numericality_of: generate_message(attr_name, :not_a_number, value: raw_value, message: custom_message)
def test_generate_message_not_a_number_with_default_message
assert_equal "is not a number", @person.errors.generate_message(:title, :not_a_number, :value => 'title')
end
@@ -107,7 +107,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase
assert_equal 'custom message title', @person.errors.generate_message(:title, :not_a_number, :message => 'custom message %{value}', :value => 'title')
end
- # validates_numericality_of: generate_message(attr_name, option, :value => raw_value, :default => custom_message)
+ # validates_numericality_of: generate_message(attr_name, option, value: raw_value, default: custom_message)
def test_generate_message_greater_than_with_default_message
assert_equal "must be greater than 10", @person.errors.generate_message(:title, :greater_than, :value => 'title', :count => 10)
end
diff --git a/activemodel/test/cases/validations/validates_test.rb b/activemodel/test/cases/validations/validates_test.rb
index 90bc018ae1..144532d6f4 100644
--- a/activemodel/test/cases/validations/validates_test.rb
+++ b/activemodel/test/cases/validations/validates_test.rb
@@ -140,7 +140,7 @@ class ValidatesTest < ActiveModel::TestCase
end
def test_validates_with_included_validator_and_wildcard_shortcut
- # Shortcut for PersonWithValidator.validates :title, :like => { :with => "Mr." }
+ # Shortcut for PersonWithValidator.validates :title, like: { with: "Mr." }
PersonWithValidator.validates :title, :like => "Mr."
person = PersonWithValidator.new
person.title = "Ms. Pacman"
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb
index b989a1e161..99e7383d42 100644
--- a/activerecord/lib/active_record/associations/association.rb
+++ b/activerecord/lib/active_record/associations/association.rb
@@ -223,7 +223,7 @@ module ActiveRecord
end
# This should be implemented to return the values of the relevant key(s) on the owner,
- # so that when state_state is different from the value stored on the last find_target,
+ # so that when stale_state is different from the value stored on the last find_target,
# the target is stale.
#
# This is only relevant to certain associations, which is why it returns nil by default.
diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb
index c1cd3a4ae3..0848e7afb3 100644
--- a/activerecord/lib/active_record/associations/preloader.rb
+++ b/activerecord/lib/active_record/associations/preloader.rb
@@ -72,7 +72,7 @@ module ActiveRecord
# books.
# - a Hash which specifies multiple association names, as well as
# association names for the to-be-preloaded association objects. For
- # example, specifying <tt>{ :author => :avatar }</tt> will preload a
+ # example, specifying <tt>{ author: :avatar }</tt> will preload a
# book's author, as well as that author's avatar.
#
# +:associations+ has the same format as the +:include+ option for
@@ -80,8 +80,8 @@ module ActiveRecord
#
# :books
# [ :books, :author ]
- # { :author => :avatar }
- # [ :books, { :author => :avatar } ]
+ # { author: :avatar }
+ # [ :books, { author: :avatar } ]
def initialize(records, associations, preload_scope = nil)
@records = Array.wrap(records).compact.uniq
@associations = Array.wrap(associations)
diff --git a/activerecord/lib/active_record/associations/singular_association.rb b/activerecord/lib/active_record/associations/singular_association.rb
index 32f4557c28..10238555f0 100644
--- a/activerecord/lib/active_record/associations/singular_association.rb
+++ b/activerecord/lib/active_record/associations/singular_association.rb
@@ -12,7 +12,7 @@ module ActiveRecord
target
end
- # Implements the writer method, e.g. foo.items= for Foo.has_many :items
+ # Implements the writer method, e.g. foo.bar= for Foo.belongs_to :bar
def writer(record)
replace(record)
end
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb
index b9e014735b..43520142bf 100644
--- a/activerecord/lib/active_record/associations/through_association.rb
+++ b/activerecord/lib/active_record/associations/through_association.rb
@@ -28,7 +28,7 @@ module ActiveRecord
# methods which create and delete records on the association.
#
# We only support indirectly modifying through associations which has a belongs_to source.
- # This is the "has_many :tags, :through => :taggings" situation, where the join model
+ # This is the "has_many :tags, through: :taggings" situation, where the join model
# typically has a belongs_to on both side. In other words, associations which could also
# be represented as has_and_belongs_to_many associations.
#
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb
index 101c641877..437fd00948 100644
--- a/activerecord/lib/active_record/attribute_methods.rb
+++ b/activerecord/lib/active_record/attribute_methods.rb
@@ -215,10 +215,10 @@ module ActiveRecord
# person = Person.create!(name: 'David Heinemeier Hansson ' * 3)
#
# person.attribute_for_inspect(:name)
- # # => '"David Heinemeier Hansson David Heinemeier Hansson D..."'
+ # # => "\"David Heinemeier Hansson David Heinemeier Hansson D...\""
#
# person.attribute_for_inspect(:created_at)
- # # => '"2009-01-12 04:48:57"'
+ # # => "\"2012-10-22 00:15:07\""
def attribute_for_inspect(attr_name)
value = read_attribute(attr_name)
@@ -234,14 +234,18 @@ module ActiveRecord
# Returns +true+ if the specified +attribute+ has been set by the user or by a
# database load and is neither +nil+ nor <tt>empty?</tt> (the latter only applies
# to objects that respond to <tt>empty?</tt>, most notably Strings). Otherwise, +false+.
+ # Note that it always returns +true+ with boolean attributes.
#
- # class Person < ActiveRecord::Base
+ # class Task < ActiveRecord::Base
# end
#
- # person = Person.new(name: '')
- # person.attribute_present?(:name) # => false
+ # person = Task.new(title: '', is_done: false)
+ # person.attribute_present?(:title) # => false
+ # person.attribute_present?(:is_done) # => true
# person.name = 'Francesco'
- # person.attribute_present?(:name) # => true
+ # person.is_done = true
+ # person.attribute_present?(:title) # => true
+ # person.attribute_present?(:is_done) # => true
def attribute_present?(attribute)
value = read_attribute(attribute)
!value.nil? && !(value.respond_to?(:empty?) && value.empty?)
@@ -265,15 +269,16 @@ module ActiveRecord
end
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
- # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
- # (Alias for the protected <tt>read_attribute</tt> method). It raises an <tt>ActiveModel::MissingAttributeError</tt>
- # error if the identified attribute is missing.
+ # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)). It raises
+ # <tt>ActiveModel::MissingAttributeError</tt> if the identified attribute is missing.
+ #
+ # Alias for the <tt>read_attribute</tt> method.
#
# class Person < ActiveRecord::Base
# belongs_to :organization
# end
#
- # person = Person.new(name: 'Francesco', age: '22'
+ # person = Person.new(name: 'Francesco', age: '22')
# person[:name] # => "Francesco"
# person[:age] # => 22
#
diff --git a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb
index d4f529acbf..a23baeaced 100644
--- a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb
+++ b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb
@@ -1,5 +1,28 @@
module ActiveRecord
module AttributeMethods
+ # = Active Record Attribute Methods Before Type Cast
+ #
+ # <tt>ActiveRecord::AttributeMethods::BeforeTypeCast</tt> provides a way to
+ # read the value of the attributes before typecasting and deserialization.
+ #
+ # class Task < ActiveRecord::Base
+ # end
+ #
+ # task = Task.new(id: '1', completed_on: '2012-10-21')
+ # task.id # => 1
+ # task.completed_on # => Sun, 21 Oct 2012
+ #
+ # task.attributes_before_type_cast
+ # # => {"id"=>"1", "completed_on"=>"2012-10-21", ... }
+ # task.read_attribute_before_type_cast('id') # => "1"
+ # task.read_attribute_before_type_cast('completed_on') # => "2012-10-21"
+ #
+ # In addition to #read_attribute_before_type_cast and #attributes_before_type_cast,
+ # it declares a method for all attributes with the <tt>*_before_type_cast</tt>
+ # suffix.
+ #
+ # task.id_before_type_cast # => "1"
+ # task.completed_on_before_type_cast # => "2012-10-21"
module BeforeTypeCast
extend ActiveSupport::Concern
@@ -7,11 +30,31 @@ module ActiveRecord
attribute_method_suffix "_before_type_cast"
end
+ # Returns the value of the attribute identified by +attr_name+ before
+ # typecasting and deserialization.
+ #
+ # class Task < ActiveRecord::Base
+ # end
+ #
+ # task = Task.new(id: '1', completed_on: '2012-10-21')
+ # task.read_attribute('id') # => 1
+ # task.read_attribute_before_type_cast('id') # => '1'
+ # task.read_attribute('completed_on') # => Sun, 21 Oct 2012
+ # task.read_attribute_before_type_cast('completed_on') # => "2012-10-21"
def read_attribute_before_type_cast(attr_name)
@attributes[attr_name]
end
# Returns a hash of attributes before typecasting and deserialization.
+ #
+ # class Task < ActiveRecord::Base
+ # end
+ #
+ # task = Task.new(title: nil, is_done: true, completed_on: '2012-10-21')
+ # task.attributes
+ # # => {"id"=>nil, "title"=>nil, "is_done"=>true, "completed_on"=>Sun, 21 Oct 2012, "created_at"=>nil, "updated_at"=>nil}
+ # task.attributes_before_type_cast
+ # # => {"id"=>nil, "title"=>nil, "is_done"=>true, "completed_on"=>"2012-10-21", "created_at"=>nil, "updated_at"=>nil}
def attributes_before_type_cast
@attributes
end
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index 3aabf3b3f2..725bfffef2 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -212,11 +212,10 @@ module ActiveRecord
#
# before_destroy :log_children
#
- # def log_children
- # children.each do |child|
- # # Some child processing
+ # private
+ # def log_children
+ # # Child processing
# end
- # end
# end
#
# In this case, the problem is that when the +before_destroy+ callback is executed, the children are not available
@@ -227,11 +226,10 @@ module ActiveRecord
#
# before_destroy :log_children, prepend: true
#
- # def log_children
- # children.each do |child|
- # # Some child processing
+ # private
+ # def log_children
+ # # Child processing
# end
- # end
# end
#
# This way, the +before_destroy+ gets executed before the <tt>dependent: destroy</tt> is called, and the data is still available.
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
index 0d7046a705..4f3eebce7d 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -150,7 +150,7 @@ module ActiveRecord
# already-automatically-released savepoints:
#
# Model.connection.transaction do # BEGIN
- # Model.connection.transaction(:requires_new => true) do # CREATE SAVEPOINT active_record_1
+ # Model.connection.transaction(requires_new: true) do # CREATE SAVEPOINT active_record_1
# Model.connection.create_table(...)
# # active_record_1 now automatically released
# end # RELEASE SAVEPOINT active_record_1 <--- BOOM! database error!
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index 0f6b177b62..38960ab873 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -161,21 +161,21 @@ module ActiveRecord
# td.column(:granted, :boolean)
# # granted BOOLEAN
#
- # td.column(:picture, :binary, :limit => 2.megabytes)
+ # td.column(:picture, :binary, limit: 2.megabytes)
# # => picture BLOB(2097152)
#
- # td.column(:sales_stage, :string, :limit => 20, :default => 'new', :null => false)
+ # td.column(:sales_stage, :string, limit: 20, default: 'new', null: false)
# # => sales_stage VARCHAR(20) DEFAULT 'new' NOT NULL
#
- # td.column(:bill_gates_money, :decimal, :precision => 15, :scale => 2)
+ # td.column(:bill_gates_money, :decimal, precision: 15, scale: 2)
# # => bill_gates_money DECIMAL(15,2)
#
- # td.column(:sensor_reading, :decimal, :precision => 30, :scale => 20)
+ # td.column(:sensor_reading, :decimal, precision: 30, scale: 20)
# # => sensor_reading DECIMAL(30,20)
#
# # While <tt>:scale</tt> defaults to zero on most databases, it
# # probably wouldn't hurt to include it.
- # td.column(:huge_integer, :decimal, :precision => 30)
+ # td.column(:huge_integer, :decimal, precision: 30)
# # => huge_integer DECIMAL(30)
#
# # Defines a column with a database-specific type.
@@ -190,11 +190,11 @@ module ActiveRecord
#
# What can be written like this with the regular calls to column:
#
- # create_table "products", :force => true do |t|
+ # create_table "products", force: true do |t|
# t.column "shop_id", :integer
# t.column "creator_id", :integer
- # t.column "name", :string, :default => "Untitled"
- # t.column "value", :string, :default => "Untitled"
+ # t.column "name", :string, default: "Untitled"
+ # t.column "value", :string, default: "Untitled"
# t.column "created_at", :datetime
# t.column "updated_at", :datetime
# end
@@ -203,7 +203,7 @@ module ActiveRecord
#
# create_table :products do |t|
# t.integer :shop_id, :creator_id
- # t.string :name, :value, :default => "Untitled"
+ # t.string :name, :value, default: "Untitled"
# t.timestamps
# end
#
@@ -218,17 +218,17 @@ module ActiveRecord
# create_table :taggings do |t|
# t.integer :tag_id, :tagger_id, :taggable_id
# t.string :tagger_type
- # t.string :taggable_type, :default => 'Photo'
+ # t.string :taggable_type, default: 'Photo'
# end
- # add_index :taggings, :tag_id, :name => 'index_taggings_on_tag_id'
+ # add_index :taggings, :tag_id, name: 'index_taggings_on_tag_id'
# add_index :taggings, [:tagger_id, :tagger_type]
#
# Can also be written as follows using references:
#
# create_table :taggings do |t|
- # t.references :tag, :index => { :name => 'index_taggings_on_tag_id' }
- # t.references :tagger, :polymorphic => true, :index => true
- # t.references :taggable, :polymorphic => { :default => 'Photo' }
+ # t.references :tag, index: { name: 'index_taggings_on_tag_id' }
+ # t.references :tagger, polymorphic: true, index: true
+ # t.references :taggable, polymorphic: { default: 'Photo' }
# end
def column(name, type, options = {})
name = name.to_s
@@ -266,7 +266,7 @@ module ActiveRecord
# Adds index options to the indexes hash, keyed by column name
# This is primarily used to track indexes that need to be created after the table
#
- # index(:account_id, :name => 'index_projects_on_account_id')
+ # index(:account_id, name: 'index_projects_on_account_id')
def index(column_name, options = {})
indexes[column_name] = options
end
@@ -374,9 +374,9 @@ module ActiveRecord
# ====== Creating a simple index
# t.index(:name)
# ====== Creating a unique index
- # t.index([:branch_id, :party_id], :unique => true)
+ # t.index([:branch_id, :party_id], unique: true)
# ====== Creating a named index
- # t.index([:branch_id, :party_id], :unique => true, :name => 'by_branch_party')
+ # t.index([:branch_id, :party_id], unique: true, name: 'by_branch_party')
def index(column_name, options = {})
@base.add_index(@table_name, column_name, options)
end
@@ -396,7 +396,7 @@ module ActiveRecord
# Changes the column's definition according to the new options.
# See TableDefinition#column for details of the options you can use.
#
- # t.change(:name, :string, :limit => 80)
+ # t.change(:name, :string, limit: 80)
# t.change(:description, :text)
def change(column_name, type, options = {})
@base.change_column(@table_name, column_name, type, options)
@@ -423,11 +423,11 @@ module ActiveRecord
# ====== Remove the index_table_name_on_column in the table_name table
# t.remove_index :column
# ====== Remove the index named index_table_name_on_branch_id in the table_name table
- # t.remove_index :column => :branch_id
+ # t.remove_index column: :branch_id
# ====== Remove the index named index_table_name_on_branch_id_and_party_id in the table_name table
- # t.remove_index :column => [:branch_id, :party_id]
+ # t.remove_index column: [:branch_id, :party_id]
# ====== Remove the index named by_branch_party in the table_name table
- # t.remove_index :name => :by_branch_party
+ # t.remove_index name: :by_branch_party
def remove_index(options = {})
@base.remove_index(@table_name, options)
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 86d6266af9..8790518d37 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -36,10 +36,10 @@ module ActiveRecord
# index_exists?(:suppliers, [:company_id, :company_type])
#
# # Check a unique index exists
- # index_exists?(:suppliers, :company_id, :unique => true)
+ # index_exists?(:suppliers, :company_id, unique: true)
#
# # Check an index with a custom name exists
- # index_exists?(:suppliers, :company_id, :name => "idx_company_id"
+ # index_exists?(:suppliers, :company_id, name: "idx_company_id"
def index_exists?(table_name, column_name, options = {})
column_names = Array(column_name)
index_name = options.key?(:name) ? options[:name].to_s : index_name(table_name, :column => column_names)
@@ -89,14 +89,14 @@ module ActiveRecord
# # table.
#
# create_table(:suppliers) do |t|
- # t.column :name, :string, :limit => 60
+ # t.column :name, :string, limit: 60
# # Other fields here
# end
#
# === Block form, with shorthand
# # You can also use the column types as method calls, rather than calling the column method.
# create_table(:suppliers) do |t|
- # t.string :name, :limit => 60
+ # t.string :name, limit: 60
# # Other fields here
# end
#
@@ -104,7 +104,7 @@ module ActiveRecord
# # Creates a table called 'suppliers' with no columns.
# create_table(:suppliers)
# # Add a column to 'suppliers'.
- # add_column(:suppliers, :name, :string, {:limit => 60})
+ # add_column(:suppliers, :name, :string, {limit: 60})
#
# The +options+ hash can include the following keys:
# [<tt>:id</tt>]
@@ -127,15 +127,15 @@ module ActiveRecord
# Defaults to false.
#
# ====== Add a backend specific option to the generated SQL (MySQL)
- # create_table(:suppliers, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8')
+ # create_table(:suppliers, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8')
# generates:
# CREATE TABLE suppliers (
# id int(11) DEFAULT NULL auto_increment PRIMARY KEY
# ) ENGINE=InnoDB DEFAULT CHARSET=utf8
#
# ====== Rename the primary key column
- # create_table(:objects, :primary_key => 'guid') do |t|
- # t.column :name, :string, :limit => 80
+ # create_table(:objects, primary_key: 'guid') do |t|
+ # t.column :name, :string, limit: 80
# end
# generates:
# CREATE TABLE objects (
@@ -144,7 +144,7 @@ module ActiveRecord
# )
#
# ====== Do not add a primary key column
- # create_table(:categories_suppliers, :id => false) do |t|
+ # create_table(:categories_suppliers, id: false) do |t|
# t.column :category_id, :integer
# t.column :supplier_id, :integer
# end
@@ -193,7 +193,7 @@ module ActiveRecord
# Defaults to false.
#
# ====== Add a backend specific option to the generated SQL (MySQL)
- # create_join_table(:assemblies, :parts, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8')
+ # create_join_table(:assemblies, :parts, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8')
# generates:
# CREATE TABLE assemblies_parts (
# assembly_id int NOT NULL,
@@ -218,7 +218,7 @@ module ActiveRecord
#
# # change_table() yields a Table instance
# change_table(:suppliers) do |t|
- # t.column :name, :string, :limit => 60
+ # t.column :name, :string, limit: 60
# # Other column alterations here
# end
#
@@ -231,12 +231,12 @@ module ActiveRecord
#
# ====== Add a column
# change_table(:suppliers) do |t|
- # t.column :name, :string, :limit => 60
+ # t.column :name, :string, limit: 60
# end
#
# ====== Add 2 integer columns
# change_table(:suppliers) do |t|
- # t.integer :width, :height, :null => false, :default => 0
+ # t.integer :width, :height, null: false, default: 0
# end
#
# ====== Add created_at/updated_at columns
@@ -253,7 +253,7 @@ module ActiveRecord
#
# ====== Add a polymorphic foreign key column
# change_table(:suppliers) do |t|
- # t.belongs_to :company, :polymorphic => true
+ # t.belongs_to :company, polymorphic: true
# end
#
# Creates <tt>company_type(varchar)</tt> and <tt>company_id(integer)</tt> columns
@@ -318,7 +318,7 @@ module ActiveRecord
# Changes the column's definition according to the new options.
# See TableDefinition#column for details of the options you can use.
#
- # change_column(:suppliers, :name, :string, :limit => 80)
+ # change_column(:suppliers, :name, :string, limit: 80)
# change_column(:accounts, :description, :text)
def change_column(table_name, column_name, type, options = {})
raise NotImplementedError, "change_column is not implemented"
@@ -352,35 +352,35 @@ module ActiveRecord
# CREATE INDEX suppliers_name_index ON suppliers(name)
#
# ====== Creating a unique index
- # add_index(:accounts, [:branch_id, :party_id], :unique => true)
+ # add_index(:accounts, [:branch_id, :party_id], unique: true)
# generates
# CREATE UNIQUE INDEX accounts_branch_id_party_id_index ON accounts(branch_id, party_id)
#
# ====== Creating a named index
- # add_index(:accounts, [:branch_id, :party_id], :unique => true, :name => 'by_branch_party')
+ # add_index(:accounts, [:branch_id, :party_id], unique: true, name: 'by_branch_party')
# generates
# CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id)
#
# ====== Creating an index with specific key length
- # add_index(:accounts, :name, :name => 'by_name', :length => 10)
+ # add_index(:accounts, :name, name: 'by_name', length: 10)
# generates
# CREATE INDEX by_name ON accounts(name(10))
#
- # add_index(:accounts, [:name, :surname], :name => 'by_name_surname', :length => {:name => 10, :surname => 15})
+ # add_index(:accounts, [:name, :surname], name: 'by_name_surname', length: {name: 10, surname: 15})
# generates
# CREATE INDEX by_name_surname ON accounts(name(10), surname(15))
#
# Note: SQLite doesn't support index length
#
# ====== Creating an index with a sort order (desc or asc, asc is the default)
- # add_index(:accounts, [:branch_id, :party_id, :surname], :order => {:branch_id => :desc, :party_id => :asc})
+ # add_index(:accounts, [:branch_id, :party_id, :surname], order: {branch_id: :desc, party_id: :asc})
# generates
# CREATE INDEX by_branch_desc_party ON accounts(branch_id DESC, party_id ASC, surname)
#
# Note: mysql doesn't yet support index order (it accepts the syntax but ignores it)
#
# ====== Creating a partial index
- # add_index(:accounts, [:branch_id, :party_id], :unique => true, :where => "active")
+ # add_index(:accounts, [:branch_id, :party_id], unique: true, where: "active")
# generates
# CREATE UNIQUE INDEX index_accounts_on_branch_id_and_party_id ON accounts(branch_id, party_id) WHERE active
#
@@ -396,11 +396,11 @@ module ActiveRecord
# Remove the index_accounts_on_column in the accounts table.
# remove_index :accounts, :column
# Remove the index named index_accounts_on_branch_id in the accounts table.
- # remove_index :accounts, :column => :branch_id
+ # remove_index :accounts, column: :branch_id
# Remove the index named index_accounts_on_branch_id_and_party_id in the accounts table.
- # remove_index :accounts, :column => [:branch_id, :party_id]
+ # remove_index :accounts, column: [:branch_id, :party_id]
# Remove the index named by_branch_party in the accounts table.
- # remove_index :accounts, :name => :by_branch_party
+ # remove_index :accounts, name: :by_branch_party
def remove_index(table_name, options = {})
remove_index!(table_name, index_name_for_remove(table_name, options))
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
index 2c57b52017..84e73e6f0f 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -353,9 +353,9 @@ module ActiveRecord
# Charset defaults to utf8.
#
# Example:
- # create_database 'charset_test', :charset => 'latin1', :collation => 'latin1_bin'
+ # create_database 'charset_test', charset: 'latin1', collation: 'latin1_bin'
# create_database 'matt_development'
- # create_database 'matt_development', :charset => :big5
+ # create_database 'matt_development', charset: :big5
def create_database(name, options = {})
if options[:collation]
execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET `#{options[:charset] || 'utf8'}` COLLATE `#{options[:collation]}`"
diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
index 879eec7fcf..f55d19393c 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
@@ -175,7 +175,7 @@ module ActiveRecord
# # as values.
# def select_one(sql, name = nil)
# result = execute(sql, name)
- # result.each(:as => :hash) do |r|
+ # result.each(as: :hash) do |r|
# return r
# end
# end
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
index 7cad8f94cf..82a0b662f4 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -16,7 +16,7 @@ module ActiveRecord
#
# Example:
# create_database config[:database], config
- # create_database 'foo_development', :encoding => 'unicode'
+ # create_database 'foo_development', encoding: 'unicode'
def create_database(name, options = {})
options = options.reverse_merge(:encoding => "utf8")
diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb
index 0637dd58b6..04c0fbfe70 100644
--- a/activerecord/lib/active_record/errors.rb
+++ b/activerecord/lib/active_record/errors.rb
@@ -193,6 +193,17 @@ module ActiveRecord
end
+ # Raised when a relation cannot be mutated because it's already loaded.
+ #
+ # class Task < ActiveRecord::Base
+ # end
+ #
+ # relation = Task.all
+ # relation.loaded? # => true
+ #
+ # # Methods which try to mutate a loaded relation fail.
+ # relation.where!(title: 'TODO') # => ActiveRecord::ImmutableRelation
+ # relation.limit!(5) # => ActiveRecord::ImmutableRelation
class ImmutableRelation < ActiveRecordError
end
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 6bc5cd1fb9..29a99a5336 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -657,6 +657,7 @@ module ActiveRecord
#--
# Deprecate 'Fixtures' in favor of 'FixtureSet'.
#++
+ # :nodoc:
Fixtures = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveRecord::Fixtures', 'ActiveRecord::FixtureSet')
class Fixture #:nodoc:
diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb
index d026c50ee6..aba56c2861 100644
--- a/activerecord/lib/active_record/nested_attributes.rb
+++ b/activerecord/lib/active_record/nested_attributes.rb
@@ -105,7 +105,7 @@ module ActiveRecord
# ]
# }}
#
- # member = Member.create(params['member'])
+ # member = Member.create(params[:member])
# member.posts.length # => 2
# member.posts.first.title # => 'Kari, the awesome Ruby documentation browser!'
# member.posts.second.title # => 'The egalitarian assumption of the modern citizen'
@@ -127,7 +127,7 @@ module ActiveRecord
# ]
# }}
#
- # member = Member.create(params['member'])
+ # member = Member.create(params[:member])
# member.posts.length # => 2
# member.posts.first.title # => 'Kari, the awesome Ruby documentation browser!'
# member.posts.second.title # => 'The egalitarian assumption of the modern citizen'
@@ -177,7 +177,7 @@ module ActiveRecord
# :posts_attributes => [{ :id => '2', :_destroy => '1' }]
# }}
#
- # member.attributes = params['member']
+ # member.attributes = params[:member]
# member.posts.detect { |p| p.id == 2 }.marked_for_destruction? # => true
# member.posts.length # => 2
# member.save
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index c336e1f5bb..8e749772a1 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -15,18 +15,18 @@ module ActiveRecord
#
# ==== Examples
# # Create a single new object
- # User.create(:first_name => 'Jamie')
+ # User.create(first_name: 'Jamie')
#
# # Create an Array of new objects
- # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }])
+ # User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }])
#
# # Create a single object and pass it into a block to set other attributes.
- # User.create(:first_name => 'Jamie') do |u|
+ # User.create(first_name: 'Jamie') do |u|
# u.is_admin = false
# end
#
# # Creating an Array of new objects using a block, where the block is executed for each object:
- # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) do |u|
+ # User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }]) do |u|
# u.is_admin = false
# end
def create(attributes = nil, &block)
@@ -64,7 +64,7 @@ module ActiveRecord
#
# By default, save always run validations. If any of them fail the action
# is cancelled and +save+ returns +false+. However, if you supply
- # :validate => false, validations are bypassed altogether. See
+ # validate: false, validations are bypassed altogether. See
# ActiveRecord::Validations for more information.
#
# There's a series of callbacks associated with +save+. If any of the
@@ -143,7 +143,7 @@ module ActiveRecord
# inheritance structures where you want a subclass to appear as the
# superclass. This can be used along with record identification in
# Action Pack to allow, say, <tt>Client < Company</tt> to do something
- # like render <tt>:partial => @client.becomes(Company)</tt> to render that
+ # like render <tt>partial: @client.becomes(Company)</tt> to render that
# instance using the companies/company partial instead of clients/client.
#
# Note: The new instance will share a link to the same attributes as the original class.
@@ -286,7 +286,7 @@ module ActiveRecord
# Reloads the attributes of this object from the database.
# The optional options argument is passed to find when reloading so you
- # may do e.g. record.reload(:lock => true) to reload the same record with
+ # may do e.g. record.reload(lock: true) to reload the same record with
# an exclusive row lock.
def reload(options = nil)
clear_aggregation_cache
@@ -317,11 +317,11 @@ module ActiveRecord
# If used along with +belongs_to+ then +touch+ will invoke +touch+ method on associated object.
#
# class Brake < ActiveRecord::Base
- # belongs_to :car, :touch => true
+ # belongs_to :car, touch: true
# end
#
# class Car < ActiveRecord::Base
- # belongs_to :corporation, :touch => true
+ # belongs_to :corporation, touch: true
# end
#
# # triggers @brake.car.touch and @brake.car.corporation.touch
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index f322b96f79..0103de4cbd 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -81,13 +81,13 @@ module ActiveRecord
class MacroReflection
# Returns the name of the macro.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>:balance</tt>
+ # <tt>composed_of :balance, class_name: 'Money'</tt> returns <tt>:balance</tt>
# <tt>has_many :clients</tt> returns <tt>:clients</tt>
attr_reader :name
# Returns the macro type.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>:composed_of</tt>
+ # <tt>composed_of :balance, class_name: 'Money'</tt> returns <tt>:composed_of</tt>
# <tt>has_many :clients</tt> returns <tt>:has_many</tt>
attr_reader :macro
@@ -95,7 +95,7 @@ module ActiveRecord
# Returns the hash of options used for the macro.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>{ :class_name => "Money" }</tt>
+ # <tt>composed_of :balance, class_name: 'Money'</tt> returns <tt>{ class_name: "Money" }</tt>
# <tt>has_many :clients</tt> returns +{}+
attr_reader :options
@@ -115,7 +115,7 @@ module ActiveRecord
# Returns the class for the macro.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns the Money class
+ # <tt>composed_of :balance, class_name: 'Money'</tt> returns the Money class
# <tt>has_many :clients</tt> returns the Client class
def klass
@klass ||= class_name.constantize
@@ -123,7 +123,7 @@ module ActiveRecord
# Returns the class name for the macro.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>'Money'</tt>
+ # <tt>composed_of :balance, class_name: 'Money'</tt> returns <tt>'Money'</tt>
# <tt>has_many :clients</tt> returns <tt>'Client'</tt>
def class_name
@class_name ||= (options[:class_name] || derive_class_name).to_s
@@ -315,10 +315,10 @@ module ActiveRecord
# the parent's validation.
#
# Unless you explicitly disable validation with
- # <tt>:validate => false</tt>, validation will take place when:
+ # <tt>validate: false</tt>, validation will take place when:
#
- # * you explicitly enable validation; <tt>:validate => true</tt>
- # * you use autosave; <tt>:autosave => true</tt>
+ # * you explicitly enable validation; <tt>validate: true</tt>
+ # * you use autosave; <tt>autosave: true</tt>
# * the association is a +has_many+ association
def validate?
!options[:validate].nil? ? options[:validate] : (options[:autosave] == true || macro == :has_many)
@@ -399,7 +399,7 @@ module ActiveRecord
#
# class Post < ActiveRecord::Base
# has_many :taggings
- # has_many :tags, :through => :taggings
+ # has_many :tags, through: :taggings
# end
#
def source_reflection
@@ -411,7 +411,7 @@ module ActiveRecord
#
# class Post < ActiveRecord::Base
# has_many :taggings
- # has_many :tags, :through => :taggings
+ # has_many :tags, through: :taggings
# end
#
# tags_reflection = Post.reflect_on_association(:tags)
@@ -439,12 +439,12 @@ module ActiveRecord
#
# class Person
# has_many :articles
- # has_many :comment_tags, :through => :articles
+ # has_many :comment_tags, through: :articles
# end
#
# class Article
# has_many :comments
- # has_many :comment_tags, :through => :comments, :source => :tags
+ # has_many :comment_tags, through: :comments, source: :tags
# end
#
# class Comment
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 2e2286e4fd..cb9cc5a9df 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -235,7 +235,7 @@ module ActiveRecord
# Scope all queries to the current scope.
#
- # Comment.where(:post_id => 1).scoping do
+ # Comment.where(post_id: 1).scoping do
# Comment.first # SELECT * FROM comments WHERE post_id = 1
# end
#
@@ -266,7 +266,7 @@ module ActiveRecord
# Book.where('title LIKE ?', '%Rails%').update_all(author: 'David')
#
# # Update all books that match conditions, but limit it to 5 ordered by date
- # Book.where('title LIKE ?', '%Rails%').order(:created_at).limit(5).update_all(:author => 'David')
+ # Book.where('title LIKE ?', '%Rails%').order(:created_at).limit(5).update_all(author: 'David')
def update_all(updates)
raise ArgumentError, "Empty list of attributes to change" if updates.blank?
@@ -339,7 +339,7 @@ module ActiveRecord
#
# Person.destroy_all("last_login < '2004-04-04'")
# Person.destroy_all(status: "inactive")
- # Person.where(:age => 0..18).destroy_all
+ # Person.where(age: 0..18).destroy_all
def destroy_all(conditions = nil)
if conditions
where(conditions).destroy_all
@@ -384,7 +384,7 @@ module ActiveRecord
#
# Post.delete_all("person_id = 5 AND (category = 'Something' OR category = 'Else')")
# Post.delete_all(["person_id = ? AND (category = ? OR category = ?)", 5, 'Something', 'Else'])
- # Post.where(:person_id => 5).where(:category => ['Something', 'Else']).delete_all
+ # Post.where(person_id: 5).where(category: ['Something', 'Else']).delete_all
#
# Both calls delete the affected posts all at once with a single DELETE statement.
# If you need to destroy dependent associations or call your <tt>before_*</tt> or
@@ -514,7 +514,7 @@ module ActiveRecord
# Joins that are also marked for preloading. In which case we should just eager load them.
# Note that this is a naive implementation because we could have strings and symbols which
# represent the same association, but that aren't matched by this. Also, we could have
- # nested hashes which partially match, e.g. { :a => :b } & { :a => [:b, :c] }
+ # nested hashes which partially match, e.g. { a: :b } & { a: [:b, :c] }
def joined_includes_values
includes_values & joins_values
end
diff --git a/activesupport/lib/active_support/core_ext/array/wrap.rb b/activesupport/lib/active_support/core_ext/array/wrap.rb
index ffaf6ef024..05b09a4c7f 100644
--- a/activesupport/lib/active_support/core_ext/array/wrap.rb
+++ b/activesupport/lib/active_support/core_ext/array/wrap.rb
@@ -23,7 +23,7 @@ class Array
# The last point is particularly worth comparing for some enumerables:
#
# Array(foo: :bar) # => [[:foo, :bar]]
- # Array.wrap(foo: :bar) # => [{foo: :bar}]
+ # Array.wrap(foo: :bar) # => [{:foo=>:bar}]
#
# There's also a related idiom that uses the splat operator:
#
diff --git a/activesupport/lib/active_support/core_ext/hash/deep_merge.rb b/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
index 83f0c87b04..e07db50b77 100644
--- a/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
+++ b/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
@@ -4,10 +4,10 @@ class Hash
# h1 = { x: { y: [4,5,6] }, z: [7,8,9] }
# h2 = { x: { y: [7,8,9] }, z: 'xyz' }
#
- # h1.deep_merge(h2) #=> {:x => {:y => [7, 8, 9]}, :z => "xyz"}
- # h2.deep_merge(h1) #=> {:x => {:y => [4, 5, 6]}, :z => [7, 8, 9]}
+ # h1.deep_merge(h2) #=> {x: {y: [7, 8, 9]}, z: "xyz"}
+ # h2.deep_merge(h1) #=> {x: {y: [4, 5, 6]}, z: [7, 8, 9]}
# h1.deep_merge(h2) { |key, old, new| Array.wrap(old) + Array.wrap(new) }
- # #=> {:x => {:y => [4, 5, 6, 7, 8, 9]}, :z => [7, 8, 9, "xyz"]}
+ # #=> {:x=>{:y=>[4, 5, 6, 7, 8, 9]}, :z=>[7, 8, 9, "xyz"]}
def deep_merge(other_hash, &block)
dup.deep_merge!(other_hash, &block)
end
diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb
index a92c5968ed..9fa9b3dac4 100644
--- a/activesupport/lib/active_support/core_ext/hash/slice.rb
+++ b/activesupport/lib/active_support/core_ext/hash/slice.rb
@@ -21,7 +21,7 @@ class Hash
# Returns a hash containing the removed key/value pairs.
#
# { a: 1, b: 2, c: 3, d: 4 }.slice!(:a, :b)
- # # => {c: 3, d: 4}
+ # # => {:c=>3, :d=>4}
def slice!(*keys)
keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
omit = slice(*self.keys - keys)
@@ -32,8 +32,8 @@ class Hash
# Removes and returns the key/value pairs matching the given keys.
#
- # { a: 1, b: 2, c: 3, d: 4 }.extract!(:a, :b) # => { a: 1, b: 2 }
- # { a: 1, b: 2 }.extract!(:a, :x) # => { a: 1 }
+ # { a: 1, b: 2, c: 3, d: 4 }.extract!(:a, :b) # => {:a=>1, :b=>2}
+ # { a: 1, b: 2 }.extract!(:a, :x) # => {:a=>1}
def extract!(*keys)
keys.each_with_object(self.class.new) { |key, result| result[key] = delete(key) if has_key?(key) }
end
diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb
index 6edfcd7493..341e2deec9 100644
--- a/activesupport/lib/active_support/core_ext/string/inflections.rb
+++ b/activesupport/lib/active_support/core_ext/string/inflections.rb
@@ -38,7 +38,7 @@ class String
end
# The reverse of +pluralize+, returns the singular form of a word in a string.
- #
+ #
# If the optional parameter +locale+ is specified,
# the word will be singularized as a word of that language.
# By default, this paramter is set to <tt>:en</tt>.
@@ -160,7 +160,7 @@ class String
# @person = Person.find(1)
# # => #<Person id: 1, name: "Donald E. Knuth">
#
- # <%= link_to(@person.name, person_path %>
+ # <%= link_to(@person.name, person_path) %>
# # => <a href="/person/1-donald-e-knuth">Donald E. Knuth</a>
def parameterize(sep = '-')
ActiveSupport::Inflector.parameterize(self, sep)
diff --git a/guides/source/3_1_release_notes.md b/guides/source/3_1_release_notes.md
index 1d79ea5b5a..d3f8abe0c8 100644
--- a/guides/source/3_1_release_notes.md
+++ b/guides/source/3_1_release_notes.md
@@ -129,6 +129,10 @@ config.static_cache_control = "public, max-age=3600"
end
```
+#### Remove :cache and :concat options in asset helpers references in views
+
+* With the Asset Pipeline the :cache and :concat options aren't used anymore, delete these options from your views.
+
Creating a Rails 3.1 application
--------------------------------
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index 824ffb5d7a..dd8d229e6a 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -66,7 +66,7 @@ class ClientsController < ActionController::Base
if params[:status] == "activated"
@clients = Client.activated
else
- @clients = Client.unactivated
+ @clients = Client.inactivated
end
end
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 76548a3397..da56d55deb 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -1087,7 +1087,7 @@ Scopes
Scoping allows you to specify commonly-used queries which can be referenced as method calls on the association objects or models. With these scopes, you can use every method previously covered such as `where`, `joins` and `includes`. All scope methods will return an `ActiveRecord::Relation` object which will allow for further methods (such as other scopes) to be called on it.
-To define a simple scope, we use the `scope` method inside the class, passing the query that we'd like run when this scope is called:
+To define a simple scope, we use the `scope` method inside the class, passing the query that we'd like to run when this scope is called:
```ruby
class Post < ActiveRecord::Base
@@ -1256,7 +1256,7 @@ creating a new record, but we don't want to include it in the query. So
we want to find the client named "Andy", or if that client doesn't
exist, create a client named "Andy" which is not locked.
-We can achive this in two ways. The first is to use `create_with`:
+We can achieve this in two ways. The first is to use `create_with`:
```ruby
Client.create_with(locked: false).find_or_create_by(first_name: 'Andy')
diff --git a/guides/source/active_record_validations_callbacks.md b/guides/source/active_record_validations_callbacks.md
index 7555ef4226..5c27ccbf9e 100644
--- a/guides/source/active_record_validations_callbacks.md
+++ b/guides/source/active_record_validations_callbacks.md
@@ -736,7 +736,7 @@ end
person = Person.new
person.valid? # => false
person.errors
- # => {name: ["can't be blank", "is too short (minimum is 3 characters)"]}
+ # => {:name=>["can't be blank", "is too short (minimum is 3 characters)"]}
person = Person.new(name: "John Doe")
person.valid? # => true
@@ -1003,7 +1003,7 @@ Callbacks can also be registered to only fire on certain lifecycle events:
```ruby
class User < ActiveRecord::Base
before_validation :normalize_name, on: :create
-
+
# :on takes an array as well
after_validation :set_location, on: [ :create, :update ]
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 122257807b..4b2cc947b5 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -2372,7 +2372,7 @@ This method is similar in purpose to `Kernel#Array`, but there are some differen
The last point is particularly worth comparing for some enumerables:
```ruby
-Array.wrap(foo: :bar) # => [{foo: :bar}]
+Array.wrap(foo: :bar) # => [{:foo=>:bar}]
Array(foo: :bar) # => [[:foo, :bar]]
```
@@ -2557,7 +2557,7 @@ Ruby has a built-in method `Hash#merge` that merges two hashes:
```ruby
{a: 1, b: 1}.merge(a: 0, c: 2)
-# => {a: 0, b: 1, c: 2}
+# => {:a=>0, :b=>1, :c=>2}
```
Active Support defines a few more ways of merging hashes that may be convenient.
@@ -2602,7 +2602,7 @@ Active Support defines `Hash#deep_merge`. In a deep merge, if a key is found in
```ruby
{a: {b: 1}}.deep_merge(a: {c: 2})
-# => {a: {b: 1, c: 2}}
+# => {:a=>{:b=>1, :c=>2}}
```
The method `deep_merge!` performs a deep merge in place.
@@ -2641,17 +2641,17 @@ The method `diff` returns a hash that represents a diff of the receiver and the
# => {}, first rule
{a: 1}.diff(a: 2)
-# => {a: 1}, second rule
+# => {:a=>1}, second rule
{a: 1}.diff(b: 2)
-# => {a: 1, b: 2}, third rule
+# => {:a=>1, :b=>2}, third rule
{a: 1, b: 2, c: 3}.diff(b: 1, c: 3, d: 4)
-# => {a: 1, b: 2, d: 4}, all rules
+# => {:a=>1, :b=>2, :d=>4}, all rules
{}.diff({}) # => {}
-{a: 1}.diff({}) # => {a: 1}
-{}.diff(a: 1) # => {a: 1}
+{a: 1}.diff({}) # => {:a=>1}
+{}.diff(a: 1) # => {:a=>1}
```
An important property of this diff hash is that you can retrieve the original hash by applying `diff` twice:
@@ -2671,7 +2671,7 @@ NOTE: Defined in `active_support/core_ext/hash/diff.rb`.
The method `except` returns a hash with the keys in the argument list removed, if present:
```ruby
-{a: 1, b: 2}.except(:a) # => {b: 2}
+{a: 1, b: 2}.except(:a) # => {:b=>2}
```
If the receiver responds to `convert_key`, the method is called on each of the arguments. This allows `except` to play nice with hashes with indifferent access for instance:
@@ -2776,7 +2776,7 @@ The method `symbolize_keys` returns a hash that has a symbolized version of the
```ruby
{nil => nil, 1 => 1, "a" => "a"}.symbolize_keys
-# => {1 => 1, nil => nil, a: "a"}
+# => {1=>1, nil=>nil, :a=>"a"}
```
WARNING. Note in the previous example only one key was symbolized.
@@ -2785,7 +2785,7 @@ The result in case of collision is undefined:
```ruby
{"a" => 1, a: 2}.symbolize_keys
-# => {a: 2}, in my test, can't rely on this result though
+# => {:a=>2}, in my test, can't rely on this result though
```
This method may be useful for example to easily accept both symbols and strings as options. For instance `ActionController::UrlRewriter` defines
@@ -2836,17 +2836,17 @@ Ruby has built-in support for taking slices out of strings and arrays. Active Su
```ruby
{a: 1, b: 2, c: 3}.slice(:a, :c)
-# => {c: 3, a: 1}
+# => {:c=>3, :a=>1}
{a: 1, b: 2, c: 3}.slice(:b, :X)
-# => {b: 2} # non-existing keys are ignored
+# => {:b=>2} # non-existing keys are ignored
```
If the receiver responds to `convert_key` keys are normalized:
```ruby
{a: 1, b: 2}.with_indifferent_access.slice("a")
-# => {a: 1}
+# => {:a=>1}
```
NOTE. Slicing may come in handy for sanitizing option hashes with a white list of keys.
@@ -2855,8 +2855,8 @@ There's also `slice!` which in addition to perform a slice in place returns what
```ruby
hash = {a: 1, b: 2}
-rest = hash.slice!(:a) # => {b: 2}
-hash # => {a: 1}
+rest = hash.slice!(:a) # => {:b=>2}
+hash # => {:a=>1}
```
NOTE: Defined in `active_support/core_ext/hash/slice.rb`.
@@ -2867,8 +2867,8 @@ The method `extract!` removes and returns the key/value pairs matching the given
```ruby
hash = {a: 1, b: 2}
-rest = hash.extract!(:a) # => {a: 1}
-hash # => {b: 2}
+rest = hash.extract!(:a) # => {:a=>1}
+hash # => {:b=>2}
```
The method `extract!` returns the same subclass of Hash, that the receiver is.
diff --git a/guides/source/active_support_instrumentation.md b/guides/source/active_support_instrumentation.md
index b35691bbcc..1163940f10 100644
--- a/guides/source/active_support_instrumentation.md
+++ b/guides/source/active_support_instrumentation.md
@@ -434,7 +434,7 @@ ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*a
event.name # => "process_action.action_controller"
event.duration # => 10 (in milliseconds)
- event.payload # => { extra: :information }
+ event.payload # => {:extra=>information}
Rails.logger.info "#{event} Received!"
end
@@ -477,7 +477,7 @@ Now you can listen to this event with:
```ruby
ActiveSupport::Notifications.subscribe "my.custom.event" do |name, started, finished, unique_id, data|
- puts data.inspect # { this: :data }
+ puts data.inspect # {:this=>:data}
end
```
diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md
index fc0092a93e..0540516a74 100644
--- a/guides/source/asset_pipeline.md
+++ b/guides/source/asset_pipeline.md
@@ -386,6 +386,9 @@ generates something like this:
<link href="/assets/application-4dd5b109ee3439da54f5bdfd78a80473.css" media="screen" rel="stylesheet" />
```
+Note: with the Asset Pipeline the :cache and :concat options aren't used anymore, delete these options from the `javascript_include_tag` and `stylesheet_link_tag`.
+
+
The fingerprinting behavior is controlled by the setting of `config.assets.digest` setting in Rails (which defaults to `true` for production and `false` for everything else).
NOTE: Under normal circumstances the default option should not be changed. If there are no digests in the filenames, and far-future headers are set, remote clients will never know to refetch the files when their content changes.
diff --git a/guides/source/configuring.md b/guides/source/configuring.md
index ab2766054b..0b4f183d61 100644
--- a/guides/source/configuring.md
+++ b/guides/source/configuring.md
@@ -133,7 +133,7 @@ These configuration methods are to be called on a `Rails::Railtie` object, such
### Configuring Assets
-Rails 3.1, by default, is set up to use the `sprockets` gem to manage assets within an application. This gem concatenates and compresses assets in order to make serving them much less painful.
+Rails 3.1 and up, by default, is set up to use the `sprockets` gem to manage assets within an application. This gem concatenates and compresses assets in order to make serving them much less painful.
* `config.assets.enabled` a flag that controls whether the asset pipeline is enabled. It is explicitly initialized in `config/application.rb`.
diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md
index 6e843062ec..3791467584 100644
--- a/guides/source/contributing_to_ruby_on_rails.md
+++ b/guides/source/contributing_to_ruby_on_rails.md
@@ -208,6 +208,7 @@ Rails follows a simple set of coding style conventions.
* Two spaces, no tabs (for indentation).
* No trailing whitespace. Blank lines should not have any spaces.
* Indent after private/protected.
+* Use Ruby >= 1.9 syntax for hashes. Prefer `{ a: :b }` over `{ :a => :b }`.
* Prefer `&&`/`||` over `and`/`or`.
* Prefer class << self over self.method for class methods.
* Use `MyClass.my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`.
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index e916bda630..9d8287ab7c 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -546,7 +546,7 @@ Also, a key can translate to a (potentially nested) hash of grouped translations
```ruby
I18n.t 'activerecord.errors.messages'
-# => { inclusion: "is not included in the list", exclusion: ... }
+# => {:inclusion=>"is not included in the list", :exclusion=> ... }
```
#### "Lazy" Lookup
diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md
index 8277859232..5f4f7e8511 100644
--- a/guides/source/layouts_and_rendering.md
+++ b/guides/source/layouts_and_rendering.md
@@ -124,7 +124,7 @@ Cache-Control: no-cache
$
```
-We see there is an empty response (no data after the `Cache-Control` line), but the request was successful because Rails has set the response to 200 OK. You can set the `:status` option on render to change this response. Rendering nothing can be useful for AJAX requests where all you want to send back to the browser is an acknowledgment that the request was completed.
+We see there is an empty response (no data after the `Cache-Control` line), but the request was successful because Rails has set the response to 200 OK. You can set the `:status` option on render to change this response. Rendering nothing can be useful for Ajax requests where all you want to send back to the browser is an acknowledgment that the request was completed.
TIP: You should probably be using the `head` method, discussed later in this guide, instead of `render :nothing`. This provides additional flexibility and makes it explicit that you're only generating HTTP headers.
@@ -259,13 +259,13 @@ You can send plain text - with no markup at all - back to the browser by using t
render :text => "OK"
```
-TIP: Rendering pure text is most useful when you're responding to AJAX or web service requests that are expecting something other than proper HTML.
+TIP: Rendering pure text is most useful when you're responding to Ajax or web service requests that are expecting something other than proper HTML.
NOTE: By default, if you use the `:text` option, the text is rendered without using the current layout. If you want Rails to put the text into the current layout, you need to add the `:layout => true` option.
#### Rendering JSON
-JSON is a JavaScript data format used by many AJAX libraries. Rails has built-in support for converting objects to JSON and rendering that JSON back to the browser:
+JSON is a JavaScript data format used by many Ajax libraries. Rails has built-in support for converting objects to JSON and rendering that JSON back to the browser:
```ruby
render :json => @product
diff --git a/guides/source/migrations.md b/guides/source/migrations.md
index 3eeb45f8c6..314ee3f5cd 100644
--- a/guides/source/migrations.md
+++ b/guides/source/migrations.md
@@ -684,8 +684,9 @@ version to migrate to.
The `rake db:reset` task will drop the database, recreate it and load the
current schema into it.
-NOTE: This is not the same as running all the migrations - see the section on
-[schema.rb](#schema-dumping-and-you).
+NOTE: This is not the same as running all the migrations. It will only use the contents
+of the current schema.rb file. If a migration can't be rolled back, 'rake db:reset'
+may not help you. To find out more about dumping the schema see [schema.rb](#schema-dumping-and-you).
### Running Specific Migrations
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index d57bb1f8bc..05a1714966 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -271,3 +271,7 @@ or
```bash
$ rake db:sessions:clear
```
+
+### Remove :cache and :concat options in asset helpers references in views
+
+* With the Asset Pipeline the :cache and :concat options aren't used anymore, delete these options from your views.
diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md
index bb736eb670..011303c311 100644
--- a/guides/source/working_with_javascript_in_rails.md
+++ b/guides/source/working_with_javascript_in_rails.md
@@ -138,6 +138,7 @@ and Rails has got your back in those cases.
Because of Unobtrusive JavaScript, the Rails "Ajax helpers" are actually in two
parts: the JavaScript half and the Ruby half.
+
[rails.js](https://github.com/rails/jquery-ujs/blob/master/src/rails.js)
provides the JavaScript half, and the regular Ruby view helpers add appropriate
tags to your DOM. The CoffeeScript in rails.js then listens for these