rails将lib添加到eager_load_paths而不指定目录

时间:2015-09-11 00:20:47

标签: ruby-on-rails puma

我发现autoload_paths在生产中导致循环依赖,所以我将lib放到eager_load_paths。

config.eager_load_paths << Rails.root.join("lib")

但我有一个active_record模板文件,其路径为"#{Rails.root}/templates/active_record/model/model.rb"

<% module_namespacing do -%>
class <%= class_name %> < <%= parent_class_name.classify %>
# accessors .................................................................
# extends ...................................................................
# includes ..................................................................
# relationships .............................................................
<% attributes.select(&:reference?).each do |attribute| -%>
  belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %>
<% end -%>
# validations ...............................................................
# callbacks .................................................................
# scopes ....................................................................
# additional config .........................................................
<% if attributes.any?(&:password_digest?) -%>
  has_secure_password
<% end -%>
# class methods .............................................................
# public instance methods ...................................................
# protected instance methods ................................................
# private instance methods ..................................................
end
<% end -%>

Puma认为它是一个ruby文件,因此在启动时会出现语法错误。

那么,如何在没有指定目录的情况下急切加载lib路径?

0 个答案:

没有答案