-
Notifications
You must be signed in to change notification settings - Fork 29
DOCSP-46555: rails integration #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
ffe73d3
2f171a8
251b614
4e170f0
bac51b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,136 @@ | ||||||||||
.. _mongoid-rails-integration: | ||||||||||
|
||||||||||
================= | ||||||||||
Rails Integration | ||||||||||
================= | ||||||||||
|
||||||||||
.. facet:: | ||||||||||
:name: genre | ||||||||||
:values: reference | ||||||||||
|
||||||||||
.. meta:: | ||||||||||
:keywords: web framework, api, code example, ruby | ||||||||||
|
||||||||||
.. contents:: On this page | ||||||||||
:local: | ||||||||||
:backlinks: none | ||||||||||
:depth: 2 | ||||||||||
:class: singlecol | ||||||||||
|
||||||||||
Overview | ||||||||||
-------- | ||||||||||
|
||||||||||
In this guide, you can learn about features that are automatically | ||||||||||
enabled when you use {+odm+} in a {+ror+} application. This guide also | ||||||||||
describes Rails-related functionality that you can enable in your application. | ||||||||||
|
||||||||||
Configuration | ||||||||||
------------- | ||||||||||
|
||||||||||
You can configure {+odm+}-specific options and other Rails-environment | ||||||||||
specific options in your main application file by accessing | ||||||||||
``config.mongoid``. The ``mongoid:config`` generator creates an | ||||||||||
initializer in the ``config/initializers/mongoid.rb`` file. | ||||||||||
|
||||||||||
.. note:: | ||||||||||
|
||||||||||
Any options set in your ``config/mongoid.yml`` file | ||||||||||
take precedence over options set elsewhere. For this reason, use | ||||||||||
``mongoid.yml`` as the default location for {+odm+} configuration | ||||||||||
when possible. | ||||||||||
|
||||||||||
.. TODO To learn more about available configuration options, | ||||||||||
see the :ref:`` section. | ||||||||||
|
||||||||||
The following code demonstrates how to create a Rails logger by | ||||||||||
accessing ``config.mongoid``: | ||||||||||
|
||||||||||
.. code-block:: ruby | ||||||||||
|
||||||||||
module MyApplication | ||||||||||
class Application < Rails::Application | ||||||||||
config.mongoid.logger = Logger.new(STDERR, :warn) | ||||||||||
end | ||||||||||
end | ||||||||||
|
||||||||||
.. TODO To learn more about logging settings, see the :ref:`` guide. | ||||||||||
|
||||||||||
Model Preloading | ||||||||||
---------------- | ||||||||||
|
||||||||||
To set up single collection inheritance, {+odm+} must preload all | ||||||||||
models before every request in development mode. This can slow down your | ||||||||||
application, so if you are not using any inheritance you can turn this | ||||||||||
feature off. | ||||||||||
|
||||||||||
The following code demonstrates how you can set the ``preload_models`` | ||||||||||
feature to off by accessing ``config.mongoid``: | ||||||||||
|
The following code demonstrates how you can set the ``preload_models`` | |
feature to off by accessing ``config.mongoid``: | |
The following code demonstrates how you can turn off preloading by setting the ``preload_models`` | |
feature to `false` by accessing ``config.mongoid``: |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a really broad heading for this section which is specifically about execution time logging. Unless there are other types of logs that can be discussed here, I think the title should be changed:
Controller Runtime Instrumentation | |
Execution Time Logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be tightly linked to the Add to an Existing App section - should they maybe be nested together in a
Mongoid with Ruby Frameworks
section?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe even just framework integration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or Integrations and Tools