From 254693a39c73b6fc9ad71b47b4d652e8738bec12 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Fri, 6 Feb 2015 13:47:51 -0700 Subject: Document the usage of the default option to attribute --- activerecord/lib/active_record/attributes.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activerecord/lib/active_record') 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 -- cgit v1.2.3