Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2864

override_database default database strange behavior

    XMLWordPrintable

    Details

      Description

      I don't know if this is me misunderstanding how mongoid works or if it's a real bug but i'm experiencing some issues around Mongoid.override_database

      here's what i do basically on app controller:

      1. I retrieve an object from the default database (before_filter 1)
      2. depending to that object i switch the database using Mongoid.override_database (before_filter 2)
      4. other controller code happen, querying the freshly switched database
      3. I set Mongoid.override_database to nil (after_filter)

      sometimes everything's fine. but sometimes on the next request it tries to query the previous database instead of the default one (the one defined in mongoid.yml)

      i tried to specify which database to use using with(database: Mongoid.default_session.options[:database]) to make sure my first object is correctly loaded but it appears that this one is changed too.

      i feel i'm maybe misunderstanding something but in any case this is a bit confusing

        Attachments

          Activity

            People

            Assignee:
            arthurnn Arthur Nogueira Neves
            Reporter:
            AlexandreBernard AlexandreBernard [X] (Inactive)
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: