• Sean McGivern's avatar
    Always use rails mode for Oj · b76f47f8
    Sean McGivern authored
    Oj's `object` mode is the default, and serialises symbols as
    `":foo"` (so the result of calling `#inspect` on the symbol). The
    `rails` mode, which is what we want, serialises them as the result of
    calling `#to_s`, so just `"foo"`.
    
    We set Oj's default mode to `rails` in an initialiser. However, this
    happens after we've already made a call that uses Oj - in
    `active_record_lifecycle.rb`, we add a hook to log when the ActiveRecord
    connection was established.
    
    For Puma, that hook will run after the worker start, which is also after
    the initialiser. However, running a console or a Rake task (like
    migrations) will run that hook immediately, so it's before we've set the
    default options, and uses `object` mode. Moving the initialiser to those
    that run before autoloading lets us sidestep this and always use `rails`
    mode.
    b76f47f8
oj.rb 128 Bytes