From 6963e8959f67029903e305d29c2856a481418065 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 2 Nov 2013 18:08:36 -0200 Subject: Fix to work on Ruby 1.9.3, example and changelog improvements --- activerecord/lib/active_record/enum.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb index 13b843ff4f..60af6b4178 100644 --- a/activerecord/lib/active_record/enum.rb +++ b/activerecord/lib/active_record/enum.rb @@ -2,7 +2,7 @@ module ActiveRecord # Declare an enum attribute where the values map to integers in the database, but can be queried by name. Example: # # class Conversation < ActiveRecord::Base - # enum status: %i( active archived ) + # enum status: [:active, :archived] # end # # Conversation::STATUS # => { active: 0, archived: 1 } @@ -11,21 +11,21 @@ module ActiveRecord # conversation.active! # conversation.active? # => true # conversation.status # => :active - # + # # # conversation.update! status: 1 # conversation.archived! # conversation.archived? # => true # conversation.status # => :archived - # + # # # conversation.update! status: 1 # conversation.status = :archived # # You can set the default value from the database declaration, like: # - # create_table :conversation do + # create_table :conversations do |t| # t.column :status, :integer, default: 0 # end - # + # # Good practice is to let the first declared status be the default. module Enum def enum(definitions) -- cgit v1.2.3