mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
edit pass to apply API guideline wrt the use of "# =>" in example code
This commit is contained in:
parent
a7a6a2ff46
commit
755af49755
19 changed files with 104 additions and 103 deletions
|
@ -20,7 +20,7 @@ module ActionDispatch
|
|||
# <%= link_to('Click here', :controller => 'users',
|
||||
# :action => 'new', :message => 'Welcome!') %>
|
||||
#
|
||||
# #=> Generates a link to: /users/new?message=Welcome%21
|
||||
# # Generates a link to /users/new?message=Welcome%21
|
||||
#
|
||||
# link_to, and all other functions that require URL generation functionality,
|
||||
# actually use ActionController::UrlFor under the hood. And in particular,
|
||||
|
|
|
@ -158,8 +158,8 @@ module ActiveModel
|
|||
#
|
||||
# p.errors.add(:name, "can't be blank")
|
||||
# p.errors.add(:name, "must be specified")
|
||||
# p.errors.to_xml #=> Produces:
|
||||
#
|
||||
# p.errors.to_xml
|
||||
# # =>
|
||||
# # <?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
# # <errors>
|
||||
# # <error>name can't be blank</error>
|
||||
|
|
|
@ -17,7 +17,10 @@ module ActiveModel
|
|||
end
|
||||
|
||||
# Transform the model name into a more humane format, using I18n. By default,
|
||||
# it will underscore then humanize the class name (BlogPost.model_name.human #=> "Blog post").
|
||||
# it will underscore then humanize the class name
|
||||
#
|
||||
# BlogPost.model_name.human # => "Blog post"
|
||||
#
|
||||
# Specify +options+ with additional translating options.
|
||||
def human(options={})
|
||||
return @human unless @klass.respond_to?(:lookup_ancestors) &&
|
||||
|
|
|
@ -24,20 +24,16 @@ module ActiveModel
|
|||
# end
|
||||
#
|
||||
# Which provides you with the full standard validation stack that you
|
||||
# know from ActiveRecord.
|
||||
# know from Active Record:
|
||||
#
|
||||
# person = Person.new
|
||||
# person.valid?
|
||||
# #=> true
|
||||
# person.invalid?
|
||||
# #=> false
|
||||
# person.valid? # => true
|
||||
# person.invalid? # => false
|
||||
#
|
||||
# person.first_name = 'zoolander'
|
||||
# person.valid?
|
||||
# #=> false
|
||||
# person.invalid?
|
||||
# #=> true
|
||||
# person.errors
|
||||
# #=> #<OrderedHash {:first_name=>["starts with z."]}>
|
||||
# person.valid? # => false
|
||||
# person.invalid? # => true
|
||||
# person.errors # => #<OrderedHash {:first_name=>["starts with z."]}>
|
||||
#
|
||||
# Note that ActiveModel::Validations automatically adds an +errors+ method
|
||||
# to your instances initialized with a new ActiveModel::Errors object, so
|
||||
|
|
|
@ -108,7 +108,7 @@ module ActiveRecord
|
|||
# ==== Example
|
||||
#
|
||||
# Comment.where(:post_id => 1).scoping do
|
||||
# Comment.first #=> SELECT * FROM comments WHERE post_id = 1
|
||||
# Comment.first # SELECT * FROM comments WHERE post_id = 1
|
||||
# end
|
||||
#
|
||||
# Please check unscoped if you want to remove all previous scopes (including
|
||||
|
|
|
@ -66,7 +66,8 @@ module Enumerable
|
|||
# +memo+ to the block. Handy for building up hashes or
|
||||
# reducing collections down to one object. Examples:
|
||||
#
|
||||
# %w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase } #=> {'foo' => 'FOO', 'bar' => 'BAR'}
|
||||
# %w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase }
|
||||
# # => {'foo' => 'FOO', 'bar' => 'BAR'}
|
||||
#
|
||||
# *Note* that you can't use immutable objects like numbers, true or false as
|
||||
# the memo. You would think the following returns 120, but since the memo is
|
||||
|
|
|
@ -83,12 +83,13 @@ module ActiveSupport #:nodoc:
|
|||
|
||||
include Comparable
|
||||
|
||||
# Returns <tt>-1</tt>, <tt>0</tt> or <tt>+1</tt> depending on whether the Chars object is to be sorted before,
|
||||
# equal or after the object on the right side of the operation. It accepts any object that implements +to_s+.
|
||||
# See <tt>String#<=></tt> for more details.
|
||||
# Returns -1, 0, or 1, depending on whether the Chars object is to be sorted before,
|
||||
# equal or after the object on the right side of the operation. It accepts any object
|
||||
# that implements +to_s+:
|
||||
#
|
||||
# Example:
|
||||
# 'é'.mb_chars <=> 'ü'.mb_chars # => -1
|
||||
#
|
||||
# See <tt>String#<=></tt> for more details.
|
||||
def <=>(other)
|
||||
@wrapped_string <=> other.to_s
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue