Skip to content

Commit 2244ece

Browse files
authored
MONGOID-5502: Rails framework compatibility docs (#5751)
* MONGOID-5502: Rails framework compatibility docs * Updated based on PR feedback * PR feedback updates * Fix typo * Add link to Redis adapter * Fix grammar * Fix typo * Fix spacing * Updates based on PR * updated
1 parent daebc7b commit 2244ece

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

source/includes/unicode-ballot-x.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. |x| unicode:: U+2717

source/reference/compatibility.txt

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,85 @@ are supported by Mongoid.
541541
8.0 and 8.1 stable branches.
542542

543543
.. include:: /includes/unicode-checkmark.rst
544+
.. include:: /includes/unicode-ballot-x.rst
545+
546+
Rails Frameworks Support
547+
------------------------
548+
549+
Ruby on Rails is comprised of a number of frameworks, which Mongoid attempts to
550+
provide compatibility with wherever possible.
551+
552+
Though Mongoid attempts to offer API compatibility with `Active Record <https://guides.rubyonrails.org/active_record_basics.html>`_,
553+
libraries that depend directly on Active Record may not work as expected when
554+
Mongoid is used as a drop-in replacement.
555+
556+
.. note::
557+
558+
Mongoid can be used alongside Active Record within the same application without issue.
559+
560+
.. list-table::
561+
:header-rows: 1
562+
:stub-columns: 1
563+
:class: compatibility-large no-padding
564+
565+
* - Rails Framework
566+
- Supported?
567+
568+
* - ``ActionCable``
569+
- |checkmark| [#rails-actioncable-dependency]_
570+
571+
* - ``ActionMailbox``
572+
- |x| [#rails-activerecord-dependency]_
573+
574+
* - ``ActionMailer``
575+
- |checkmark|
576+
577+
* - ``ActionPack``
578+
- |checkmark|
579+
580+
* - ``ActionText``
581+
- |x| [#rails-activerecord-dependency]_
582+
583+
* - ``ActionView``
584+
- |checkmark|
585+
586+
* - ``ActiveJob``
587+
- |checkmark| [#rails-activejob-dependency]_
588+
589+
* - ``ActiveModel``
590+
- |checkmark| [#rails-activemodel-dependency]_
591+
592+
* - ``ActiveStorage``
593+
- |x| [#rails-activerecord-dependency]_
594+
595+
* - ``ActiveSupport``
596+
- |checkmark| [#rails-activesupport-dependency]_
597+
598+
.. [#rails-actioncable-dependency] There is currently no MongoDB adapter for
599+
``ActionCable``, however any existing adapter (such as `Redis <https://guides.rubyonrails.org/action_cable_overview.html#redis-adapter>`_)
600+
can be used successfully in conjunction with Mongoid models
601+
602+
.. [#rails-activerecord-dependency] Depends directly on ``ActiveRecord``
603+
604+
.. [#rails-activemodel-dependency] ``Mongoid::Document`` includes ``ActiveModel::Model``
605+
and leverages ``ActiveModel::Validations`` for validations
606+
607+
.. [#rails-activesupport-dependency] ``Mongoid`` requires ``ActiveSupport`` and
608+
uses it extensively, including ``ActiveSupport::TimeWithZone`` for time handling.
609+
610+
611+
612+
.. [#rails-activejob-dependency] Serialization of BSON & Mongoid objects works best
613+
if you explicitly send ``BSON::ObjectId``'s as strings, and reconstitute them in the job:
614+
615+
.. code-block:: ruby
616+
617+
record = Model.find(...)
618+
MyJob.perform_later(record._id.to_s)
619+
620+
class MyJob < ApplicationJob
621+
def perform(id_as_string)
622+
record = Model.find(id_as_string)
623+
# ...
624+
end
625+
end

0 commit comments

Comments
 (0)