From 2e7756aa2f08b7750939594ba22dc8ff20efc0e8 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 4 Dec 2013 17:45:42 +0100 Subject: mention Active Record enums as major feature for 4.1. [ci skip] --- guides/source/4_1_release_notes.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'guides') diff --git a/guides/source/4_1_release_notes.md b/guides/source/4_1_release_notes.md index 3362f3ae06..6cdb28ad50 100644 --- a/guides/source/4_1_release_notes.md +++ b/guides/source/4_1_release_notes.md @@ -69,11 +69,13 @@ that `bin/rails` and `bin/rake` will automatically take advantage preloaded spring environments. **running rake tasks:** + ``` bin/rake routes ``` **running tests:** + ``` bin/rake test bin/rake test test/models @@ -81,6 +83,7 @@ bin/rake test test/models/user_test.rb ``` **running a console:** + ``` bin/rails console ``` @@ -100,6 +103,26 @@ Have a look at the [Spring README](https://github.com/jonleighton/spring/blob/master/README.md) to see a all available features. +### Active Record enums + +Declare an enum attribute where the values map to integers in the database, but +can be queried by name. + +```ruby +class Conversation < ActiveRecord::Base + enum status: [ :active, :archived ] +end + +conversation.archive! +conversation.active? # => false +conversation.status # => "archived" + +Conversation.archived # => Relation for all archived Conversations +``` + +See +[active_record/enum.rb](https://github.com/rails/rails/blob/4-1-stable/activerecord/lib/active_record/enum.rb#L2-L42) +for a detailed write up. Documentation ------------- -- cgit v1.2.3