aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-02-06 13:47:51 -0700
committerSean Griffin <sean@thoughtbot.com>2015-02-06 13:47:51 -0700
commit254693a39c73b6fc9ad71b47b4d652e8738bec12 (patch)
tree9e8b813a1e9803b81ff0028903773f1b9c1ed68f /activerecord/lib/active_record
parent009e3d0b2906df35339e74a8308d07863b33b648 (diff)
downloadrails-254693a39c73b6fc9ad71b47b4d652e8738bec12.tar.gz
rails-254693a39c73b6fc9ad71b47b4d652e8738bec12.tar.bz2
rails-254693a39c73b6fc9ad71b47b4d652e8738bec12.zip
Document the usage of the default option to attribute
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/attributes.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attributes.rb b/activerecord/lib/active_record/attributes.rb
index 8ba341efa6..70b8c1c635 100644
--- a/activerecord/lib/active_record/attributes.rb
+++ b/activerecord/lib/active_record/attributes.rb
@@ -63,6 +63,20 @@ module ActiveRecord
# # after
# store_listing.price_in_cents # => 10
#
+ # A default can also be provided.
+ #
+ # create_table :store_listings, force: true do |t|
+ # t.string :my_string, default: "original default"
+ # end
+ #
+ # StoreListing.new.my_string # => "original default"
+ #
+ # class StoreListing < ActiveRecord::Base
+ # attribute :my_string, :string, default: "new default"
+ # end
+ #
+ # StoreListing.new.my_string # => "new default"
+ #
# Attributes do not need to be backed by a database column.
#
# class MyModel < ActiveRecord::Base