问题描述
我在子文件夹 app/decorators
# app/models/document.rb
class Document < ApplicationRecord
def url
# ...
end
end
和定义的序列化器:
class DocumentSerializer < ActiveModel::Serializer
attributes :url
end
当我更改方法 def url
时,Rails 6 重新加载模型但不重新加载序列化程序,因此我需要重新启动服务器。
我尝试将子文件夹添加到 autoload_paths
,但不幸的是,它没有帮助:
module MyApp
class Application < Rails::Application
config.load_defaults 6.0
# config.autoloader = :classic
# config.autoload_paths += Dir[Rails.root.join("app","serializers","**","*.{rb}")]
# ...
end
end
此外,我已经尝试应用这些答案,但没有任何帮助:
Rails doesn't detect file changes and config.reload_classes_only_on_change makes the server too slow
Custom folders not auto-reloading in Rails 6
active model serializer not working with rails-api gem
附言
Rails 6.1.0
红宝石 2.7.2p137
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)