NameError on starting Rails application that does not use ActiveRecord
ignisf opened this issue · 2 comments
ignisf commented
Hi,
Disclaimer: I consider this to be outside of the normal way people use Rails, but I wanted to report it anyway. I am totally fine with you closing this as an unsupported use case :).
If one tries to use meta_request
within a Rails app that explicitly does not load ActiveRecord, the following error gets raised:
5: from /Users/xxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/meta_request-0.7.0/lib/meta_request/event.rb:66:in `block in transform_hash'
4: from /Users/xxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/meta_request-0.7.0/lib/meta_request/event.rb:41:in `block in json_encodable'
3: from /Users/xxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `load_missing_constant'
2: from /Users/xxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:76:in `rescue in load_missing_constant'
1: from /Users/xxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
/Users/xxx/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:76:in `block in load_missing_constant': uninitialized constant MetaRequest::Event::ActiveRecord (NameError)
It is caused due to the expression in the condition here attempting to load the ActiveRecord
constant:
rails_panel/meta_request/lib/meta_request/event.rb
Lines 41 to 43 in 7b5af66
rgaufman commented
Any solution for this?
ignisf commented
Maybe check if ActiveRecord
is defined (Object.const_defined?('ActiveRecord')
) or compare ancestor names as strings?