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

Where should I place my extend code of mongoid in my rails project?

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I want to change the logic of mongoid's to_json by following code:

      module Mongoid
        module Document
          def as_json(options={})
            attrs = super(options)
            attrs["id"] = self.persisted? ? self._id : nil
            attrs
          end
        end
      end
      

      where should I place it? So far I place it in application.rb and it can be loaded when starting rails. However, I want to move it to other place, where should I move to?

            Assignee:
            Unassigned Unassigned
            Reporter:
            mingmingpao mingmingpao
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: