Skip to content

Commit 5bfe737

Browse files
authored
MONGOID-5458 Document fallbacks option on localized fields (#5439)
1 parent b461b76 commit 5bfe737

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/reference/fields.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,24 @@ language, translations will be looked up in the fallback languages:
15021502
I18n.locale = :de
15031503
product.description # "Marvelous!"
15041504

1505+
Mongoid also defines a ``:fallbacks`` option on fields, which can be used to
1506+
disable fallback functionality on a specific field:
1507+
1508+
.. code:: ruby
1509+
1510+
class Product
1511+
include Mongoid::Document
1512+
field :description, type: String, localize: true, fallbacks: false
1513+
end
1514+
1515+
product = Product.new
1516+
I18n.locale = :en
1517+
product.description = "Marvelous!"
1518+
I18n.locale = :de
1519+
product.description # nil
1520+
1521+
Note that this option defaults to ``true``.
1522+
15051523
.. note::
15061524

15071525
In i18n 1.1, the behavior of fallbacks `changed <https://github.com/ruby-i18n/i18n/pull/415>`_

0 commit comments

Comments
 (0)