diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-12-04 17:45:42 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-12-04 17:45:42 +0100 |
commit | 2e7756aa2f08b7750939594ba22dc8ff20efc0e8 (patch) | |
tree | f66e609a0c2d078bc2e1c69e862745c6182c5299 | |
parent | 8bd09e0f1e9df0432550983aa2a9af4435e94568 (diff) | |
download | rails-2e7756aa2f08b7750939594ba22dc8ff20efc0e8.tar.gz rails-2e7756aa2f08b7750939594ba22dc8ff20efc0e8.tar.bz2 rails-2e7756aa2f08b7750939594ba22dc8ff20efc0e8.zip |
mention Active Record enums as major feature for 4.1. [ci skip]
-rw-r--r-- | guides/source/4_1_release_notes.md | 23 |
1 files changed, 23 insertions, 0 deletions
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 ------------- |