Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Hash Syntax to 1.9 related changes

  • Loading branch information...
commit be4a4cd38ff2c2db0f6b69bb72fb3557bd5a6e21 1 parent 20c574c
@AvnerCohen AvnerCohen authored
Showing with 346 additions and 346 deletions.
  1. +1 −1  actionpack/lib/action_view/base.rb
  2. +17 −17 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  3. +6 −6 actionpack/lib/action_view/helpers/atom_feed_helper.rb
  4. +5 −5 actionpack/lib/action_view/helpers/capture_helper.rb
  5. +94 −94 actionpack/lib/action_view/helpers/date_helper.rb
  6. +1 −1  actionpack/lib/action_view/helpers/debug_helper.rb
  7. +22 −22 actionpack/lib/action_view/helpers/form_options_helper.rb
  8. +54 −54 actionpack/lib/action_view/helpers/form_tag_helper.rb
  9. +4 −4 actionpack/lib/action_view/helpers/javascript_helper.rb
  10. +56 −56 actionpack/lib/action_view/helpers/number_helper.rb
  11. +3 −3 actionpack/lib/action_view/helpers/record_tag_helper.rb
  12. +2 −2 actionpack/lib/action_view/helpers/rendering_helper.rb
  13. +1 −1  actionpack/lib/action_view/helpers/sanitize_helper.rb
  14. +7 −7 actionpack/lib/action_view/helpers/tag_helper.rb
  15. +22 −22 actionpack/lib/action_view/helpers/text_helper.rb
  16. +1 −1  actionpack/lib/action_view/helpers/translation_helper.rb
  17. +4 −4 actionpack/lib/action_view/helpers/url_helper.rb
  18. +27 −27 actionpack/lib/action_view/renderer/partial_renderer.rb
  19. +7 −7 actionpack/lib/action_view/routing_url_for.rb
  20. +12 −12 actionpack/lib/action_view/vendor/html-scanner/html/node.rb
View
2  actionpack/lib/action_view/base.rb
@@ -55,7 +55,7 @@ module ActionView #:nodoc:
#
# You can pass local variables to sub templates by using a hash with the variable names as keys and the objects as values:
#
- # <%= render "shared/header", { :headline => "Welcome", :person => person } %>
+ # <%= render "shared/header", { headline: "Welcome", person: person } %>
#
# These can now be accessed in <tt>shared/header</tt> with:
#
View
34 actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -74,10 +74,10 @@ def javascript_include_tag(*sources)
# 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"
+ # stylesheet_link_tag "style", media: "all"
# # => <link href="/assets/style.css" media="all" rel="stylesheet" />
#
- # stylesheet_link_tag "style", :media => "print"
+ # stylesheet_link_tag "style", media: "print"
# # => <link href="/assets/style.css" media="print" rel="stylesheet" />
#
# stylesheet_link_tag "random.styles", "/css/stylish"
@@ -111,13 +111,13 @@ def stylesheet_link_tag(*sources)
# # => <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.currenthost.com/controller/action" />
# auto_discovery_link_tag(:atom)
# # => <link rel="alternate" type="application/atom+xml" title="ATOM" href="http://www.currenthost.com/controller/action" />
- # auto_discovery_link_tag(:rss, {:action => "feed"})
+ # auto_discovery_link_tag(:rss, {action: "feed"})
# # => <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.currenthost.com/controller/feed" />
- # auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"})
+ # auto_discovery_link_tag(:rss, {action: "feed"}, {title: "My RSS"})
# # => <link rel="alternate" type="application/rss+xml" title="My RSS" href="http://www.currenthost.com/controller/feed" />
- # auto_discovery_link_tag(:rss, {:controller => "news", :action => "feed"})
+ # auto_discovery_link_tag(:rss, {controller: "news", action: "feed"})
# # => <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.currenthost.com/news/feed" />
- # auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", {:title => "Example RSS"})
+ # auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", {title: "Example RSS"})
# # => <link rel="alternate" type="application/rss+xml" title="Example RSS" href="http://www.example.com/feed" />
def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
if !(type == :rss || type == :atom) && tag_options[:type].blank?
@@ -157,7 +157,7 @@ def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
# will be used if you add the page to the home screen of an iPod Touch, iPhone, or iPad.
# The following call would generate such a tag:
#
- # <%= favicon_link_tag 'mb-icon.png', :rel => 'apple-touch-icon', :type => 'image/png' %>
+ # <%= favicon_link_tag 'mb-icon.png', rel: 'apple-touch-icon', type: 'image/png' %>
def favicon_link_tag(source='favicon.ico', options={})
tag('link', {
:rel => 'shortcut icon',
@@ -183,13 +183,13 @@ def favicon_link_tag(source='favicon.ico', options={})
# # => <img alt="Icon" src="/assets/icon" />
# image_tag("icon.png")
# # => <img alt="Icon" src="/assets/icon.png" />
- # image_tag("icon.png", :size => "16x10", :alt => "Edit Entry")
+ # image_tag("icon.png", size: "16x10", alt: "Edit Entry")
# # => <img src="/assets/icon.png" width="16" height="10" alt="Edit Entry" />
- # image_tag("/icons/icon.gif", :size => "16")
+ # image_tag("/icons/icon.gif", size: "16")
# # => <img src="/icons/icon.gif" width="16" height="16" alt="Icon" />
- # image_tag("/icons/icon.gif", :height => '32', :width => '32')
+ # image_tag("/icons/icon.gif", height: '32', width: '32')
# # => <img alt="Icon" height="32" src="/icons/icon.gif" width="32" />
- # image_tag("/icons/icon.gif", :class => "menu_icon")
+ # image_tag("/icons/icon.gif", class: "menu_icon")
# # => <img alt="Icon" class="menu_icon" src="/icons/icon.gif" />
def image_tag(source, options={})
options = options.symbolize_keys
@@ -232,19 +232,19 @@ def image_alt(src)
# # => <video src="/videos/trailer" />
# video_tag("trailer.ogg")
# # => <video src="/videos/trailer.ogg" />
- # video_tag("trailer.ogg", :controls => true, :autobuffer => true)
+ # video_tag("trailer.ogg", controls: true, autobuffer: true)
# # => <video autobuffer="autobuffer" controls="controls" src="/videos/trailer.ogg" />
- # video_tag("trailer.m4v", :size => "16x10", :poster => "screenshot.png")
+ # video_tag("trailer.m4v", size: "16x10", poster: "screenshot.png")
# # => <video src="/videos/trailer.m4v" width="16" height="10" poster="/assets/screenshot.png" />
- # video_tag("/trailers/hd.avi", :size => "16x16")
+ # video_tag("/trailers/hd.avi", size: "16x16")
# # => <video src="/trailers/hd.avi" width="16" height="16" />
- # video_tag("/trailers/hd.avi", :height => '32', :width => '32')
+ # video_tag("/trailers/hd.avi", height: '32', width: '32')
# # => <video height="32" src="/trailers/hd.avi" width="32" />
# video_tag("trailer.ogg", "trailer.flv")
# # => <video><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
# video_tag(["trailer.ogg", "trailer.flv"])
# # => <video><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
- # video_tag(["trailer.ogg", "trailer.flv"], :size => "160x120")
+ # video_tag(["trailer.ogg", "trailer.flv"], size: "160x120")
# # => <video height="120" width="160"><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
def video_tag(*sources)
multiple_sources_tag('video', sources) do |options|
@@ -264,7 +264,7 @@ def video_tag(*sources)
# <audio src="/audios/sound" />
# audio_tag("sound.wav") # =>
# <audio src="/audios/sound.wav" />
- # audio_tag("sound.wav", :autoplay => true, :controls => true) # =>
+ # audio_tag("sound.wav", autoplay: true, controls: true) # =>
# <audio autoplay="autoplay" controls="controls" src="/audios/sound.wav" />
# audio_tag("sound.wav", "sound.mid") # =>
# <audio><source src="/audios/sound.wav" /><source src="/audios/sound.mid" /></audio>
View
12 actionpack/lib/action_view/helpers/atom_feed_helper.rb
@@ -12,7 +12,7 @@ module AtomFeedHelper
# config/routes.rb:
# Basecamp::Application.routes.draw do
# resources :posts
- # root :to => "posts#index"
+ # root to: "posts#index"
# end
#
# app/controllers/posts_controller.rb:
@@ -37,7 +37,7 @@ module AtomFeedHelper
# @posts.each do |post|
# feed.entry(post) do |entry|
# entry.title(post.title)
- # entry.content(post.body, :type => 'html')
+ # entry.content(post.body, type: 'html')
#
# entry.author do |author|
# author.name("DHH")
@@ -69,7 +69,7 @@ module AtomFeedHelper
# @posts.each do |post|
# feed.entry(post) do |entry|
# entry.title(post.title)
- # entry.content(post.body, :type => 'html')
+ # entry.content(post.body, type: 'html')
# entry.tag!('app:edited', Time.now)
#
# entry.author do |author|
@@ -80,11 +80,11 @@ module AtomFeedHelper
# end
#
# The Atom spec defines five elements (content rights title subtitle
- # summary) which may directly contain xhtml content if :type => 'xhtml'
+ # summary) which may directly contain xhtml content if type: 'xhtml'
# is specified as an attribute. If so, this helper will take care of
# the enclosing div and xhtml namespace declaration. Example usage:
#
- # entry.summary :type => 'xhtml' do |xhtml|
+ # entry.summary type: 'xhtml' do |xhtml|
# xhtml.p pluralize(order.line_items.count, "line item")
# xhtml.p "Shipped to #{order.address}"
# xhtml.p "Paid by #{order.pay_type}"
@@ -149,7 +149,7 @@ def method_missing(method, *arguments, &block)
# True if the method name matches one of the five elements defined
# in the Atom spec as potentially containing XHTML content and
- # if :type => 'xhtml' is, in fact, specified.
+ # if type: 'xhtml' is, in fact, specified.
def xhtml_block?(method, arguments)
if XHTML_TAG_NAMES.include?(method.to_s)
last = arguments.last
View
10 actionpack/lib/action_view/helpers/capture_helper.rb
@@ -99,7 +99,7 @@ def capture(*args)
#
# Then, in another view, you could to do something like this:
#
- # <%= link_to 'Logout', :action => 'logout', :remote => true %>
+ # <%= link_to 'Logout', action: 'logout', remote: true %>
#
# <% content_for :script do %>
# <%= javascript_include_tag :defaults %>
@@ -112,13 +112,13 @@ def capture(*args)
# identifier in order. For example:
#
# <% content_for :navigation do %>
- # <li><%= link_to 'Home', :action => 'index' %></li>
+ # <li><%= link_to 'Home', action: 'index' %></li>
# <% end %>
#
# <%# Add some other content, or use a different template: %>
#
# <% content_for :navigation do %>
- # <li><%= link_to 'Login', :action => 'login' %></li>
+ # <li><%= link_to 'Login', action: 'login' %></li>
# <% end %>
#
# Then, in another template or layout, this code would render both links in order:
@@ -128,13 +128,13 @@ def capture(*args)
# 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:
View
188 actionpack/lib/action_view/helpers/date_helper.rb
@@ -19,7 +19,7 @@ module Helpers
# 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 DateHelper
# 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 DateHelper
# 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 @@ def distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options
# 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 @@ def time_ago_in_words(from_time, include_seconds_or_options = {})
# 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 @@ def time_ago_in_words(from_time, include_seconds_or_options = {})
#
# # 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 @@ def date_select(object_name, method, options = {}, html_options = {})
#
# # 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 @@ def time_select(object_name, method, options = {}, html_options = {})
#
# # 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 @@ def datetime_select(object_name, method, options = {}, html_options = {})
#
# # 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 @@ def select_datetime(datetime = Time.current, options = {}, html_options = {})
#
# # 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 @@ def select_date(date = Date.current, options = {}, html_options = {})
#
# # 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 @@ def select_time(datetime = Time.current, options = {}, html_options = {})
#
# # 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 @@ def select_second(datetime, options = {}, html_options = {})
#
# # 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 @@ def select_minute(datetime, options = {}, html_options = {})
#
# # 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 @@ def select_hour(datetime, options = {}, html_options = {})
# 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 @@ def select_day(date, options = {}, html_options = {})
#
# # 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 @@ def select_month(date, options = {}, html_options = {})
#
# # 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 @@ def select_year(date, options = {}, html_options = {})
# <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 @@ def build_options_and_select(type, selected, options = {})
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 @@ def build_select(type, select_options_as_html)
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
View
2  actionpack/lib/action_view/helpers/debug_helper.rb
@@ -11,7 +11,7 @@ module DebugHelper
# 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
View
44 actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -14,7 +14,7 @@ module Helpers
#
# 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 Helpers
#
# 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 Helpers
#
# 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 Helpers
#
# 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 Helpers
#
# Example:
#
- # select("post", "category", Post::CATEGORIES, {:disabled => 'restricted'})
+ # select("post", "category", Post::CATEGORIES, {disabled: 'restricted'})
#
# could become:
#
@@ -88,7 +88,7 @@ module Helpers
#
# 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 FormOptionsHelper
# * 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 FormOptionsHelper
# 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 FormOptionsHelper
# 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 @@ def select(object, method, choices, options = {}, html_options = {})
# 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 @@ def grouped_collection_select(object, method, collection, group_method, group_la
# 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 @@ def time_zone_select(object, method, priority_zones = nil, options = {}, html_op
# 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 @@ def time_zone_select(object, method, priority_zones = nil, options = {}, html_op
# 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>
@@ -630,7 +630,7 @@ def time_zone_options_for_select(selected = nil, priority_zones = nil, model = :
# 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
@@ -693,7 +693,7 @@ def collection_radio_buttons(object, method, collection, value_method, text_meth
# 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
View
108 actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -10,7 +10,7 @@ module Helpers
# 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 FormTagHelper
# 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 FormTagHelper
# <% 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 @@ def form_tag(url_for_options = {}, options = {}, &block)
# # => <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 @@ def form_tag(url_for_options = {}, options = {}, &block)
# # => <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 @@ def select_tag(name, option_tags = nil, options = {})
# 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 @@ def text_field_tag(name, value = nil, options = {})
# 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 @@ def label_tag(name = nil, content_or_options = nil, options = nil, &block)
# 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 @@ def hidden_field_tag(name, value = nil, options = {})
# 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 @@ def hidden_field_tag(name, value = nil, options = {})
# 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 @@ def file_field_tag(name, options = {})
# 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 @@ def password_field_tag(name = "password", value = nil, options = {})
# 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 @@ def text_area_tag(name, content = nil, options = {})
# 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 @@ def check_box_tag(name, value = "1", checked = false, options = {})
# 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 @@ def radio_button_tag(name, value, checked = false, options = {})
#
# ==== 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 @@ def radio_button_tag(name, value, checked = false, options = {})
# 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 = {})
@@ -454,7 +454,7 @@ def submit_tag(value = "Save changes", options = {})
#
# ==== 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.
@@ -467,14 +467,14 @@ def submit_tag(value = "Save changes", options = {})
# 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)
@@ -510,7 +510,7 @@ def button_tag(content_or_options = nil, options = nil, &block)
#
# ==== 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.
#
@@ -518,16 +518,16 @@ def button_tag(content_or_options = nil, options = nil, &block)
# 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
@@ -557,7 +557,7 @@ def image_submit_tag(source, options = {})
# <% 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>
@@ -683,7 +683,7 @@ def email_field_tag(name, value = nil, options = {})
# * 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
View
8 actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -44,12 +44,12 @@ def escape_javascript(javascript)
#
# +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 @@ def javascript_cdata_section(content) #:nodoc:
# 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={})
@@ -95,7 +95,7 @@ def button_to_function(name, function=nil, html_options={})
#
# 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={})
View
112 actionpack/lib/action_view/helpers/number_helper.rb
@@ -45,15 +45,15 @@ def initialize(number)
# 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 @@ def number_to_phone(number, options = {})
#
# 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 @@ def number_to_currency(number, options = {})
#
# 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 @@ def number_to_percentage(number, options = {})
# 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 @@ def number_with_delimiter(number, options = {})
# ==== 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 @@ def number_with_precision(number, options = {})
# 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 @@ def number_to_human_size(number, options = {})
# 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 @@ def number_to_human_size(number, options = {})
#
# 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)
View
6 actionpack/lib/action_view/helpers/record_tag_helper.rb
@@ -7,7 +7,7 @@ module RecordTagHelper
# 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 RecordTagHelper
# 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 @@ def div_for(record, *args, &block)
# 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:
#
View
4 actionpack/lib/action_view/helpers/rendering_helper.rb
@@ -39,7 +39,7 @@ def render(options = {}, locals = {}, &block)
# 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 @@ def render(options = {}, locals = {}, &block)
# 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 %>
#
View
2  actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -29,7 +29,7 @@ module SanitizeHelper
#
# 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
#
View
14 actionpack/lib/action_view/helpers/tag_helper.rb
@@ -50,16 +50,16 @@ module TagHelper
# 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 @@ def tag(name, options = nil, open = false, escape = true)
# ==== 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>
View
44 actionpack/lib/action_view/helpers/text_helper.rb
@@ -43,7 +43,7 @@ module TextHelper
# 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 @@ def safe_concat(string)
# 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 @@ def truncate(text, options = {}, &block)
# 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 @@ def highlight(text, phrases, options = {})
# <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 @@ def pluralize(count, singular, plural = nil)
# 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 @@ def word_wrap(text, options = {})
# 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 @@ def word_wrap(text, options = {})
# 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 @@ def simple_format(text, html_options = {}, options = {})
#
#
# # 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 @@ def current_cycle(name = "default")
# <% @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 %>
View
2  actionpack/lib/action_view/helpers/translation_helper.rb
@@ -17,7 +17,7 @@ module Helpers
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,
View
8 actionpack/lib/action_view/helpers/url_helper.rb
@@ -73,17 +73,17 @@ def _back_url # :nodoc:
#
# ==== 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 @@ def _back_url # :nodoc:
#
# ==== 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
View
54 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| %>