Skip to content

Issue with autoload changed file #2416

@abratashov

Description

@abratashov

Expected behavior vs actual behavior

After changing model/library methods should serializer reloads all changes.

Steps to reproduce

When I define and change model method:

# app/models/document.rb

class Document < ApplicationRecord
  def url
    # ...
  end
end

it doesn't autoload in the serializer:

class DocumentSerializer < ActiveModel::Serializer
  attributes :url
end

After request on API it returns the previous version of url, as a result I need to restart Rails server to get changes.

#config/initializers/serializer.rb
ActiveModelSerializers.config.adapter = :json_api

Environment

ActiveModelSerializers Version (commit ref if not on tag):
active_model_serializers (0.10.12)

Output of ruby -e "puts RUBY_DESCRIPTION": ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]

OS Type & Version: Ubuntu 20.04

Integrated application and version (e.g., Rails, Grape, etc): rails (6.1.0) but also (6.1.3)

Other

Also created question
https://stackoverflow.com/questions/66496188/problem-with-active-model-serializer-auto-reloading-after-changed-files-in-rails

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions