Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 74b4d3f5219c401be755c61c83e57e4f0ff550e4 2 parents 33b4607 + c869154
Bryan Woods authored June 15, 2010

Showing 23 changed files with 169 additions and 74 deletions. Show diff stats Hide diff stats

  1. 2  actionmailer/lib/action_mailer/base.rb
  2. 16  activemodel/lib/active_model/callbacks.rb
  3. 2  activemodel/lib/active_model/dirty.rb
  4. 45  activemodel/lib/active_model/validations/acceptance.rb
  5. 40  activemodel/lib/active_model/validations/confirmation.rb
  6. 2  activemodel/lib/active_model/validations/exclusion.rb
  7. 2  activemodel/lib/active_model/validations/format.rb
  8. 2  activemodel/lib/active_model/validations/inclusion.rb
  9. 2  activemodel/lib/active_model/validations/length.rb
  10. 2  activemodel/lib/active_model/validations/numericality.rb
  11. 2  activemodel/lib/active_model/validations/presence.rb
  12. 2  activemodel/lib/active_model/validations/validates.rb
  13. 2  activemodel/lib/active_model/validations/with.rb
  14. 1  activerecord/lib/active_record/aggregations.rb
  15. 1  activerecord/lib/active_record/attribute_methods.rb
  16. 2  activerecord/lib/active_record/autosave_association.rb
  17. 2  activerecord/lib/active_record/base.rb
  18. 2  activerecord/lib/active_record/callbacks.rb
  19. 1  activerecord/lib/active_record/counter_cache.rb
  20. 5  activerecord/lib/active_record/dynamic_finder_match.rb
  21. 7  activerecord/lib/active_record/dynamic_scope_match.rb
  22. 3  activerecord/lib/active_record/errors.rb
  23. 98  activerecord/lib/active_record/migration.rb
2  actionmailer/lib/action_mailer/base.rb
@@ -395,7 +395,7 @@ def receive(raw_mail)
395 395
       end
396 396
 
397 397
       # Wraps an email delivery inside of Active Support Notifications instrumentation. This
398  
-      # method is actually called by the <tt>Mail::Message</tt> object itself through a call back
  398
+      # method is actually called by the <tt>Mail::Message</tt> object itself through a callback
399 399
       # when you call <tt>:deliver</tt> on the Mail::Message, calling +deliver_mail+ directly
400 400
       # and passing a Mail::Message will do nothing except tell the logger you sent the email.
401 401
       def deliver_mail(mail) #:nodoc:
16  activemodel/lib/active_model/callbacks.rb
@@ -2,11 +2,11 @@
2 2
 require 'active_support/callbacks'
3 3
 
4 4
 module ActiveModel
5  
-  # == Active Model Call Backs
  5
+  # == Active Model Callbacks
6 6
   # 
7 7
   # Provides an interface for any class to have Active Record like callbacks.
8 8
   # 
9  
-  # Like the Active Record methods, the call back chain is aborted as soon as
  9
+  # Like the Active Record methods, the callback chain is aborted as soon as
10 10
   # one of the methods in the chain returns false.
11 11
   #
12 12
   # First, extend ActiveModel::Callbacks from the class you are creating:
@@ -15,13 +15,13 @@ module ActiveModel
15 15
   #     extend ActiveModel::Callbacks
16 16
   #   end
17 17
   # 
18  
-  # Then define a list of methods that you want call backs attached to:
  18
+  # Then define a list of methods that you want callbacks attached to:
19 19
   # 
20 20
   #   define_model_callbacks :create, :update
21 21
   # 
22 22
   # This will provide all three standard callbacks (before, around and after) around
23 23
   # both the :create and :update methods. To implement, you need to wrap the methods 
24  
-  # you want call backs on in a block so that the call backs get a chance to fire:
  24
+  # you want callbacks on in a block so that the callbacks get a chance to fire:
25 25
   # 
26 26
   #   def create
27 27
   #     _run_create_callbacks do
@@ -61,7 +61,7 @@ def self.extended(base)
61 61
     #
62 62
     #   define_model_callbacks :initializer, :only => :after
63 63
     # 
64  
-    # Note, the <tt>:only => <type></tt> hash will apply to all call backs defined on
  64
+    # Note, the <tt>:only => <type></tt> hash will apply to all callbacks defined on
65 65
     # that method call.  To get around this you can call the define_model_callbacks
66 66
     # method as many times as you need.
67 67
     # 
@@ -72,8 +72,8 @@ def self.extended(base)
72 72
     # Would create +after_create+, +before_update+ and +around_destroy+ methods only.
73 73
     # 
74 74
     # You can pass in a class to before_<type>, after_<type> and around_<type>, in which
75  
-    # case the call back will call that class's <action>_<type> method passing the object
76  
-    # that the call back is being called on.
  75
+    # case the callback will call that class's <action>_<type> method passing the object
  76
+    # that the callback is being called on.
77 77
     # 
78 78
     #   class MyModel
79 79
     #     extend ActiveModel::Callbacks
@@ -84,7 +84,7 @@ def self.extended(base)
84 84
     # 
85 85
     #   class AnotherClass
86 86
     #     def self.before_create( obj )
87  
-    #       # obj is the MyModel instance that the call back is being called on
  87
+    #       # obj is the MyModel instance that the callback is being called on
88 88
     #     end
89 89
     #   end
90 90
     #     
2  activemodel/lib/active_model/dirty.rb
@@ -4,7 +4,7 @@
4 4
 require 'active_support/core_ext/object/duplicable'
5 5
 
6 6
 module ActiveModel
7  
-  # == Active Model Call Backs
  7
+  # == Active Model Dirty
8 8
   #
9 9
   # Provides a way to track changes in your object in the same way as 
10 10
   # Active Record does.
45  activemodel/lib/active_model/validations/acceptance.rb
... ...
@@ -1,4 +1,6 @@
1 1
 module ActiveModel
  2
+
  3
+  # == Active Model Acceptance Validator
2 4
   module Validations
3 5
     class AcceptanceValidator < EachValidator
4 6
       def initialize(options)
@@ -22,29 +24,42 @@ def setup(klass)
22 24
     end
23 25
 
24 26
     module HelperMethods
25  
-      # Encapsulates the pattern of wanting to validate the acceptance of a terms of service check box (or similar agreement). Example:
  27
+      # Encapsulates the pattern of wanting to validate the acceptance of a 
  28
+      # terms of service check box (or similar agreement). Example:
26 29
       #
27 30
       #   class Person < ActiveRecord::Base
28 31
       #     validates_acceptance_of :terms_of_service
29 32
       #     validates_acceptance_of :eula, :message => "must be abided"
30 33
       #   end
31 34
       #
32  
-      # If the database column does not exist, the +terms_of_service+ attribute is entirely virtual. This check is
33  
-      # performed only if +terms_of_service+ is not +nil+ and by default on save.
  35
+      # If the database column does not exist, the +terms_of_service+ attribute 
  36
+      # is entirely virtual. This check is performed only if +terms_of_service+
  37
+      # is not +nil+ and by default on save.
34 38
       #
35 39
       # Configuration options:
36  
-      # * <tt>:message</tt> - A custom error message (default is: "must be accepted").
37  
-      # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>).
38  
-      # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+ (default is true).
39  
-      # * <tt>:accept</tt> - Specifies value that is considered accepted.  The default value is a string "1", which
40  
-      #   makes it easy to relate to an HTML checkbox. This should be set to +true+ if you are validating a database
41  
-      #   column, since the attribute is typecast from "1" to +true+ before validation.
42  
-      # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should
43  
-      #   occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>).  The
44  
-      #   method, proc or string should return or evaluate to a true or false value.
45  
-      # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should
46  
-      #   not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>).  The
47  
-      #   method, proc or string should return or evaluate to a true or false value.
  40
+      # * <tt>:message</tt> - A custom error message (default is: "must be 
  41
+      #   accepted").
  42
+      # * <tt>:on</tt> - Specifies when this validation is active (default is
  43
+      #   <tt>:save</tt>, other options are <tt>:create</tt> and 
  44
+      #   <tt>:update</tt>).
  45
+      # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+ (default
  46
+      #   is true).
  47
+      # * <tt>:accept</tt> - Specifies value that is considered accepted. 
  48
+      #   The default value is a string "1", which makes it easy to relate to
  49
+      #   an HTML checkbox. This should be set to +true+ if you are validating 
  50
+      #   a database column, since the attribute is typecast from "1" to +true+
  51
+      #   before validation.
  52
+      # * <tt>:if</tt> - Specifies a method, proc or string to call to determine
  53
+      #   if the validation should occur (e.g. <tt>:if => :allow_validation</tt>,
  54
+      #   or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>).  The
  55
+      #   method, proc or string should return or evaluate to a true or false 
  56
+      #   value.
  57
+      # * <tt>:unless</tt> - Specifies a method, proc or string to call to 
  58
+      #   determine if the validation should not occur (for example, 
  59
+      #   <tt>:unless => :skip_validation</tt>, or 
  60
+      #   <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>).
  61
+      #   The method, proc or string should return or evaluate to a true or 
  62
+      #   false value.
48 63
       def validates_acceptance_of(*attr_names)
49 64
         validates_with AcceptanceValidator, _merge_attributes(attr_names)
50 65
       end
40  activemodel/lib/active_model/validations/confirmation.rb
... ...
@@ -1,4 +1,6 @@
1 1
 module ActiveModel
  2
+
  3
+  # == Active Model Confirmation Validator
2 4
   module Validations
3 5
     class ConfirmationValidator < EachValidator
4 6
       def validate_each(record, attribute, value)
@@ -13,33 +15,45 @@ def setup(klass)
13 15
     end
14 16
 
15 17
     module HelperMethods
16  
-      # Encapsulates the pattern of wanting to validate a password or email address field with a confirmation. Example:
  18
+      # Encapsulates the pattern of wanting to validate a password or email 
  19
+      # address field with a confirmation. For example:
17 20
       #
18 21
       #   Model:
19 22
       #     class Person < ActiveRecord::Base
20 23
       #       validates_confirmation_of :user_name, :password
21  
-      #       validates_confirmation_of :email_address, :message => "should match confirmation"
  24
+      #       validates_confirmation_of :email_address, 
  25
+      #                                 :message => "should match confirmation"
22 26
       #     end
23 27
       #
24 28
       #   View:
25 29
       #     <%= password_field "person", "password" %>
26 30
       #     <%= password_field "person", "password_confirmation" %>
27 31
       #
28  
-      # The added +password_confirmation+ attribute is virtual; it exists only as an in-memory attribute for validating the password.
29  
-      # To achieve this, the validation adds accessors to the model for the confirmation attribute. NOTE: This check is performed
30  
-      # only if +password_confirmation+ is not +nil+, and by default only on save. To require confirmation, make sure to add a presence
31  
-      # check for the confirmation attribute:
  32
+      # The added +password_confirmation+ attribute is virtual; it exists only 
  33
+      # as an in-memory attribute for validating the password. To achieve this,
  34
+      # the validation adds accessors to the model for the confirmation 
  35
+      # attribute.
  36
+      # 
  37
+      # NOTE: This check is performed only if +password_confirmation+ is not 
  38
+      # +nil+, and by default only on save. To require confirmation, make sure
  39
+      # to add a presence check for the confirmation attribute:
32 40
       #
33 41
       #   validates_presence_of :password_confirmation, :if => :password_changed?
34 42
       #
35 43
       # Configuration options:
36  
-      # * <tt>:message</tt> - A custom error message (default is: "doesn't match confirmation").
37  
-      # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>).
38  
-      # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should
39  
-      #   occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>).  The
40  
-      #   method, proc or string should return or evaluate to a true or false value.
41  
-      # * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should
42  
-      #   not occur (e.g. <tt>:unless => :skip_validation</tt>, or <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>).  The
  44
+      # * <tt>:message</tt> - A custom error message (default is: "doesn't match
  45
+      #   confirmation").
  46
+      # * <tt>:on</tt> - Specifies when this validation is active (default is
  47
+      #   <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>).
  48
+      # * <tt>:if</tt> - Specifies a method, proc or string to call to determine
  49
+      #   if the validation should occur (e.g. <tt>:if => :allow_validation</tt>,
  50
+      #   or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>).  The
  51
+      #   method, proc or string should return or evaluate to a true or false 
  52
+      #   value.
  53
+      # * <tt>:unless</tt> - Specifies a method, proc or string to call to 
  54
+      #   determine if the validation should not occur (e.g. 
  55
+      #   <tt>:unless => :skip_validation</tt>, or 
  56
+      #   <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The
43 57
       #   method, proc or string should return or evaluate to a true or false value.
44 58
       def validates_confirmation_of(*attr_names)
45 59
         validates_with ConfirmationValidator, _merge_attributes(attr_names)
2  activemodel/lib/active_model/validations/exclusion.rb
... ...
@@ -1,4 +1,6 @@
1 1
 module ActiveModel
  2
+
  3
+  # == Active Model Exclusion Validator
2 4
   module Validations
3 5
     class ExclusionValidator < EachValidator
4 6
       def check_validity!
2  activemodel/lib/active_model/validations/format.rb
... ...
@@ -1,4 +1,6 @@
1 1
 module ActiveModel
  2
+
  3
+  # == Active Model Format Validator
2 4
   module Validations
3 5
     class FormatValidator < EachValidator
4 6
       def validate_each(record, attribute, value)
2  activemodel/lib/active_model/validations/inclusion.rb
... ...
@@ -1,4 +1,6 @@
1 1
 module ActiveModel
  2
+
  3
+  # == Active Model Inclusion Validator
2 4
   module Validations
3 5
     class InclusionValidator < EachValidator
4 6
       def check_validity!
2  activemodel/lib/active_model/validations/length.rb
... ...
@@ -1,4 +1,6 @@
1 1
 module ActiveModel
  2
+
  3
+  # == Active Model Length Validator
2 4
   module Validations
3 5
     class LengthValidator < EachValidator
4 6
       MESSAGES  = { :is => :wrong_length, :minimum => :too_short, :maximum => :too_long }.freeze
2  activemodel/lib/active_model/validations/numericality.rb
... ...
@@ -1,4 +1,6 @@
1 1
 module ActiveModel
  2
+
  3
+  # == Active Model Numericality Validator
2 4
   module Validations
3 5
     class NumericalityValidator < EachValidator
4 6
       CHECKS = { :greater_than => :>, :greater_than_or_equal_to => :>=,
2  activemodel/lib/active_model/validations/presence.rb
... ...
@@ -1,6 +1,8 @@
1 1
 require 'active_support/core_ext/object/blank'
2 2
 
3 3
 module ActiveModel
  4
+
  5
+  # == Active Model Presence Validator
4 6
   module Validations
5 7
     class PresenceValidator < EachValidator
6 8
       def validate(record)
2  activemodel/lib/active_model/validations/validates.rb
... ...
@@ -1,6 +1,8 @@
1 1
 require 'active_support/core_ext/hash/slice'
2 2
 
3 3
 module ActiveModel
  4
+
  5
+  # == Active Model validates method
4 6
   module Validations
5 7
     module ClassMethods
6 8
       # This method is a shortcut to all default validators and any custom
2  activemodel/lib/active_model/validations/with.rb
... ...
@@ -1,4 +1,6 @@
1 1
 module ActiveModel
  2
+
  3
+  # == Active Model validates_with method
2 4
   module Validations
3 5
     module HelperMethods
4 6
       private
1  activerecord/lib/active_record/aggregations.rb
... ...
@@ -1,4 +1,5 @@
1 1
 module ActiveRecord
  2
+  # = Active Record Aggregations
2 3
   module Aggregations # :nodoc:
3 4
     extend ActiveSupport::Concern
4 5
 
1  activerecord/lib/active_record/attribute_methods.rb
... ...
@@ -1,6 +1,7 @@
1 1
 require 'active_support/core_ext/enumerable'
2 2
 
3 3
 module ActiveRecord
  4
+  # = Active Record Attribute Methods
4 5
   module AttributeMethods #:nodoc:
5 6
     extend ActiveSupport::Concern
6 7
     include ActiveModel::AttributeMethods
2  activerecord/lib/active_record/autosave_association.rb
... ...
@@ -1,6 +1,8 @@
1 1
 require 'active_support/core_ext/array/wrap'
2 2
 
3 3
 module ActiveRecord
  4
+  # = Active Record Autosave Association
  5
+  # 
4 6
   # AutosaveAssociation is a module that takes care of automatically saving
5 7
   # your associations when the parent is saved. In addition to saving, it
6 8
   # also destroys any associations that were marked for destruction.
2  activerecord/lib/active_record/base.rb
@@ -21,6 +21,8 @@
21 21
 require 'active_record/errors'
22 22
 
23 23
 module ActiveRecord #:nodoc:
  24
+  # = Active Record 
  25
+  #
24 26
   # Active Record objects don't specify their attributes directly, but rather infer them from the table definition with
25 27
   # which they're linked. Adding, removing, and changing attributes and their type is done directly in the database. Any change
26 28
   # is instantly reflected in the Active Record objects. The mapping that binds a given Active Record class to a certain
2  activerecord/lib/active_record/callbacks.rb
... ...
@@ -1,6 +1,8 @@
1 1
 require 'active_support/core_ext/array/wrap'
2 2
 
3 3
 module ActiveRecord
  4
+  # = Active Record Callbacks
  5
+  # 
4 6
   # Callbacks are hooks into the lifecycle of an Active Record object that allow you to trigger logic
5 7
   # before or after an alteration of the object state. This can be used to make sure that associated and
6 8
   # dependent objects are deleted when +destroy+ is called (by overwriting +before_destroy+) or to massage attributes
1  activerecord/lib/active_record/counter_cache.rb
... ...
@@ -1,4 +1,5 @@
1 1
 module ActiveRecord
  2
+  # = Active Record Counter Cache
2 3
   module CounterCache
3 4
     # Resets one or more counter caches to their correct value using an SQL
4 5
     # count query.  This is useful when adding new counter caches, or if the
5  activerecord/lib/active_record/dynamic_finder_match.rb
... ...
@@ -1,4 +1,9 @@
1 1
 module ActiveRecord
  2
+
  3
+  # = Active Record Dynamic Finder Match
  4
+  # 
  5
+  # Provides dynamic attribute-based finders such as <tt>find_by_country</tt> 
  6
+  # if, for example, the <tt>Person</tt> has an attribute with that name. 
2 7
   class DynamicFinderMatch
3 8
     def self.match(method)
4 9
       df_match = self.new(method)
7  activerecord/lib/active_record/dynamic_scope_match.rb
... ...
@@ -1,4 +1,11 @@
1 1
 module ActiveRecord
  2
+
  3
+  # = Active Record Dynamic Scope Match
  4
+  # 
  5
+  # Provides dynamic attribute-based scopes such as <tt>scoped_by_price(4.99)</tt>
  6
+  # if, for example, the <tt>Product</tt> has an attribute with that name. You can
  7
+  # chain more <tt>scoped_by_* </tt> methods after the other. It acts like a named
  8
+  # scope except that it's dynamic.
2 9
   class DynamicScopeMatch
3 10
     def self.match(method)
4 11
       ds_match = self.new(method)
3  activerecord/lib/active_record/errors.rb
... ...
@@ -1,4 +1,7 @@
1 1
 module ActiveRecord
  2
+
  3
+  # = Active Record Errors
  4
+  #
2 5
   # Generic Active Record exception class.
3 6
   class ActiveRecordError < StandardError
4 7
   end
98  activerecord/lib/active_record/migration.rb
@@ -29,11 +29,15 @@ def initialize(name)
29 29
     end
30 30
   end
31 31
 
32  
-  # Migrations can manage the evolution of a schema used by several physical databases. It's a solution
33  
-  # to the common problem of adding a field to make a new feature work in your local database, but being unsure of how to
34  
-  # push that change to other developers and to the production server. With migrations, you can describe the transformations
35  
-  # in self-contained classes that can be checked into version control systems and executed against another database that
36  
-  # might be one, two, or five versions behind.
  32
+  # Active Record Migrations
  33
+  # 
  34
+  # Migrations can manage the evolution of a schema used by several physical 
  35
+  # databases. It's a solution to the common problem of adding a field to make
  36
+  # a new feature work in your local database, but being unsure of how to
  37
+  # push that change to other developers and to the production server. With 
  38
+  # migrations, you can describe the transformations in self-contained classes
  39
+  # that can be checked into version control systems and executed against 
  40
+  # another database that might be one, two, or five versions behind.
37 41
   #
38 42
   # Example of a simple migration:
39 43
   #
@@ -47,10 +51,13 @@ def initialize(name)
47 51
   #     end
48 52
   #   end
49 53
   #
50  
-  # This migration will add a boolean flag to the accounts table and remove it if you're backing out of the migration.
51  
-  # It shows how all migrations have two class methods +up+ and +down+ that describes the transformations required to implement
52  
-  # or remove the migration. These methods can consist of both the migration specific methods like add_column and remove_column,
53  
-  # but may also contain regular Ruby code for generating data needed for the transformations.
  54
+  # This migration will add a boolean flag to the accounts table and remove it 
  55
+  # if you're backing out of the migration. It shows how all migrations have 
  56
+  # two class methods +up+ and +down+ that describes the transformations 
  57
+  # required to implement or remove the migration. These methods can consist
  58
+  # of both the migration specific methods like add_column and remove_column,
  59
+  # but may also contain regular Ruby code for generating data needed for the 
  60
+  # transformations.
54 61
   #
55 62
   # Example of a more complex migration that also needs to initialize data:
56 63
   #
@@ -64,7 +71,9 @@ def initialize(name)
64 71
   #         t.integer  :position
65 72
   #       end
66 73
   #
67  
-  #       SystemSetting.create :name => "notice", :label => "Use notice?", :value => 1
  74
+  #       SystemSetting.create  :name => "notice", 
  75
+  #                             :label => "Use notice?", 
  76
+  #                             :value => 1
68 77
   #     end
69 78
   #
70 79
   #     def self.down
@@ -72,35 +81,49 @@ def initialize(name)
72 81
   #     end
73 82
   #   end
74 83
   #
75  
-  # This migration first adds the system_settings table, then creates the very first row in it using the Active Record model
76  
-  # that relies on the table. It also uses the more advanced create_table syntax where you can specify a complete table schema
77  
-  # in one block call.
  84
+  # This migration first adds the system_settings table, then creates the very 
  85
+  # first row in it using the Active Record model that relies on the table. It
  86
+  # also uses the more advanced create_table syntax where you can specify a 
  87
+  # complete table schema in one block call.
78 88
   #
79 89
   # == Available transformations
80 90
   #
81  
-  # * <tt>create_table(name, options)</tt> Creates a table called +name+ and makes the table object available to a block
82  
-  #   that can then add columns to it, following the same format as add_column. See example above. The options hash is for
83  
-  #   fragments like "DEFAULT CHARSET=UTF-8" that are appended to the create table definition.
  91
+  # * <tt>create_table(name, options)</tt> Creates a table called +name+ and 
  92
+  #   makes the table object available to a block that can then add columns to it,
  93
+  #   following the same format as add_column. See example above. The options hash 
  94
+  #   is for fragments like "DEFAULT CHARSET=UTF-8" that are appended to the create 
  95
+  #   table definition.
84 96
   # * <tt>drop_table(name)</tt>: Drops the table called +name+.
85  
-  # * <tt>rename_table(old_name, new_name)</tt>: Renames the table called +old_name+ to +new_name+.
86  
-  # * <tt>add_column(table_name, column_name, type, options)</tt>: Adds a new column to the table called +table_name+
  97
+  # * <tt>rename_table(old_name, new_name)</tt>: Renames the table called +old_name+ 
  98
+  #   to +new_name+.
  99
+  # * <tt>add_column(table_name, column_name, type, options)</tt>: Adds a new column 
  100
+  #   to the table called +table_name+
87 101
   #   named +column_name+ specified to be one of the following types:
88  
-  #   <tt>:string</tt>, <tt>:text</tt>, <tt>:integer</tt>, <tt>:float</tt>, <tt>:decimal</tt>, <tt>:datetime</tt>, <tt>:timestamp</tt>, <tt>:time</tt>,
89  
-  #   <tt>:date</tt>, <tt>:binary</tt>, <tt>:boolean</tt>. A default value can be specified by passing an
90  
-  #   +options+ hash like <tt>{ :default => 11 }</tt>. Other options include <tt>:limit</tt> and <tt>:null</tt> (e.g. <tt>{ :limit => 50, :null => false }</tt>)
91  
-  #   -- see ActiveRecord::ConnectionAdapters::TableDefinition#column for details.
92  
-  # * <tt>rename_column(table_name, column_name, new_column_name)</tt>: Renames a column but keeps the type and content.
93  
-  # * <tt>change_column(table_name, column_name, type, options)</tt>:  Changes the column to a different type using the same
94  
-  #   parameters as add_column.
95  
-  # * <tt>remove_column(table_name, column_name)</tt>: Removes the column named +column_name+ from the table called +table_name+.
96  
-  # * <tt>add_index(table_name, column_names, options)</tt>: Adds a new index with the name of the column. Other options include
97  
-  #   <tt>:name</tt> and <tt>:unique</tt> (e.g. <tt>{ :name => "users_name_index", :unique => true }</tt>).
98  
-  # * <tt>remove_index(table_name, index_name)</tt>: Removes the index specified by +index_name+.
  102
+  #   <tt>:string</tt>, <tt>:text</tt>, <tt>:integer</tt>, <tt>:float</tt>, 
  103
+  #   <tt>:decimal</tt>, <tt>:datetime</tt>, <tt>:timestamp</tt>, <tt>:time</tt>,
  104
+  #   <tt>:date</tt>, <tt>:binary</tt>, <tt>:boolean</tt>. A default value can be
  105
+  #   specified by passing an +options+ hash like <tt>{ :default => 11 }</tt>. 
  106
+  #   Other options include <tt>:limit</tt> and <tt>:null</tt> (e.g. 
  107
+  #   <tt>{ :limit => 50, :null => false }</tt>) -- see 
  108
+  #   ActiveRecord::ConnectionAdapters::TableDefinition#column for details.
  109
+  # * <tt>rename_column(table_name, column_name, new_column_name)</tt>: Renames
  110
+  #   a column but keeps the type and content.
  111
+  # * <tt>change_column(table_name, column_name, type, options)</tt>:  Changes 
  112
+  #   the column to a different type using the same parameters as add_column.
  113
+  # * <tt>remove_column(table_name, column_name)</tt>: Removes the column named 
  114
+  #   +column_name+ from the table called +table_name+.
  115
+  # * <tt>add_index(table_name, column_names, options)</tt>: Adds a new index 
  116
+  #   with the name of the column. Other options include
  117
+  #   <tt>:name</tt> and <tt>:unique</tt> (e.g. 
  118
+  #   <tt>{ :name => "users_name_index", :unique => true }</tt>).
  119
+  # * <tt>remove_index(table_name, index_name)</tt>: Removes the index specified 
  120
+  #   by +index_name+.
99 121
   #
100 122
   # == Irreversible transformations
101 123
   #
102  
-  # Some transformations are destructive in a manner that cannot be reversed. Migrations of that kind should raise
103  
-  # an <tt>ActiveRecord::IrreversibleMigration</tt> exception in their +down+ method.
  124
+  # Some transformations are destructive in a manner that cannot be reversed. 
  125
+  # Migrations of that kind should raise an <tt>ActiveRecord::IrreversibleMigration</tt> 
  126
+  # exception in their +down+ method.
104 127
   #
105 128
   # == Running migrations from within Rails
106 129
   #
@@ -110,13 +133,15 @@ def initialize(name)
110 133
   #   rails generate migration MyNewMigration
111 134
   #
112 135
   # where MyNewMigration is the name of your migration. The generator will
113  
-  # create an empty migration file <tt>timestamp_my_new_migration.rb</tt> in the <tt>db/migrate/</tt>
114  
-  # directory where <tt>timestamp</tt> is the UTC formatted date and time that the migration was generated.
  136
+  # create an empty migration file <tt>timestamp_my_new_migration.rb</tt> 
  137
+  # in the <tt>db/migrate/</tt> directory where <tt>timestamp</tt> is the 
  138
+  # UTC formatted date and time that the migration was generated.
115 139
   #
116 140
   # You may then edit the <tt>self.up</tt> and <tt>self.down</tt> methods of
117 141
   # MyNewMigration.
118 142
   #
119 143
   # There is a special syntactic shortcut to generate migrations that add fields to a table.
  144
+  #
120 145
   #   rails generate migration add_fieldname_to_tablename fieldname:string
121 146
   #
122 147
   # This will generate the file <tt>timestamp_add_fieldname_to_tablename</tt>, which will look like this:
@@ -191,9 +216,10 @@ def initialize(name)
191 216
   #
192 217
   # == Using a model after changing its table
193 218
   #
194  
-  # Sometimes you'll want to add a column in a migration and populate it immediately after. In that case, you'll need
195  
-  # to make a call to Base#reset_column_information in order to ensure that the model has the latest column data from
196  
-  # after the new column was added. Example:
  219
+  # Sometimes you'll want to add a column in a migration and populate it 
  220
+  # immediately after. In that case, you'll need to make a call to 
  221
+  # <tt>Base#reset_column_information</tt> in order to ensure that the model has the 
  222
+  # latest column data from after the new column was added. Example:
197 223
   #
198 224
   #   class AddPeopleSalary < ActiveRecord::Migration
199 225
   #     def self.up

0 notes on commit 74b4d3f

Please sign in to comment.
Something went wrong with that request. Please try again.