Home Rails can't find my classes after a while
Reply: 0

Rails can't find my classes after a while

user823
1#
user823 Published in April 26, 2018, 5:30 pm

I have a custom module with a class in Rails. I put this in my autoload inside the application.rb

config.autoload_paths << "#{Rails.root}/classes"

The module has a reference to a file in a deeper folder:

a.rb

require_relative './b/b.rb'

module A

  def self.abc content
    return A::B.new
  end

end

B has nothing fancy:

b.rb

module A

  class B
    def initialize
    end
  end
end

What's happening right now is that in the beginning this works perfectly, but after some requests, or a certain amount of time, it stops working and I get an: uninitialized constant A::B error.

Any ideas? The fact that it works in the beginning is confusing me. Thanks in advance.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310665 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO