With latest Spina (2.11.0) and Spina Pro (0.8.0), when Rails.application.config.eager_load is set to true, Rails application fails to start. The error:
`method_missing': undefined method `attr_json_accepts_nested_attributes_for' for #<Class:0x0000000116dbff08> (NoMethodError)
The cause
TLDR; The class Spina::Pro::PageRevision is missing include AttrJson::NestedAttributes
Background
TranslatedContent calls the method attr_json_accepts_nested_attributes_for which comes from AttrJson::NestedAttributes, but TranslatedContent does not explicitly include AttrJson::NestedAttributes. The assumption is that any class that includes TranslatedContent will include AttrJson::NestedAttributes too. However, Spina::Pro::PageRevision does not.
With eager_load set to false, the same exception is raised the very first time PageRevision is accessed. Subsequent attempts to access PageRevision work as expected.
How to reproduce
This happens in a brand new rails app with Spina pro:
Create a rails app and add spina pro, following all instructions.
Set eager_load to true in config/environments/development.rb
Run rails server or console
See error
This seems like kind of a big deal since Rails sets eager_load to true in production by default.
The problem
With latest Spina (2.11.0) and Spina Pro (0.8.0), when
Rails.application.config.eager_load
is set to true, Rails application fails to start. The error:The cause
TLDR; The class
Spina::Pro::PageRevision
is missinginclude AttrJson::NestedAttributes
Background TranslatedContent calls the method
attr_json_accepts_nested_attributes_for
which comes fromAttrJson::NestedAttributes
, but TranslatedContent does not explicitly include AttrJson::NestedAttributes. The assumption is that any class that includesTranslatedContent
will includeAttrJson::NestedAttributes
too. However, Spina::Pro::PageRevision does not.With
eager_load
set tofalse
, the same exception is raised the very first timePageRevision
is accessed. Subsequent attempts to access PageRevision work as expected.How to reproduce
This happens in a brand new rails app with Spina pro:
eager_load
totrue
inconfig/environments/development.rb
This seems like kind of a big deal since Rails sets eager_load to true in production by default.