aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/active_record_querying.md17
-rw-r--r--guides/source/api_app.md8
2 files changed, 19 insertions, 6 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index f0e4ee83c5..ed1c3e7061 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -1402,8 +1402,7 @@ If you want to find both by name and locked, you can chain these finders togethe
Enums
-----
-Rails have a convenient keyword `enum`, used to map an integer column to a set
-of possible values.
+The `enum` macro maps an integer column to a set of possible values.
```ruby
class Book < ActiveRecord::Base
@@ -1411,18 +1410,24 @@ class Book < ActiveRecord::Base
end
```
-Enums are a simple way to reduce boilerplate code, since it automatically
-creates [scopes](#scopes) and adds some sintax sugar while querying.
+This will automatically create the corresponding [scopes](#scopes) to query the
+model. Methods to transition between states and query the current state are also
+added.
```ruby
# Both examples below query just available books.
Book.available
# or
Book.where(availability: :available)
+
+book = Book.new(availability: :available)
+book.available? # => true
+book.unavailable! # => true
+book.available? # => false
```
-Read the full documentation for enums
-[in the Rails API](http://api.rubyonrails.org/classes/ActiveRecord/Enum.html).
+Read the full documentation about enums
+[in the Rails API docs](http://api.rubyonrails.org/classes/ActiveRecord/Enum.html).
Understanding The Method Chaining
---------------------------------
diff --git a/guides/source/api_app.md b/guides/source/api_app.md
index fb3127555e..17695c5db0 100644
--- a/guides/source/api_app.md
+++ b/guides/source/api_app.md
@@ -163,6 +163,14 @@ class definition:
config.api_only = true
```
+Optionally, in `config/environments/development.rb` add the following line
+to render error responses using the API format (JSON by default) when it
+is a local request:
+
+```ruby
+config.debug_exception_response_format = :api
+```
+
Finally, inside `app/controllers/application_controller.rb`, instead of:
```ruby