0

I use Puma and Rails 4.2.

My concern is set up like this:

Class Order
  module Chartable
     ...
  end
end

The order class is set up like this:

Class Order
  include Chartable
end

In development, the code showed no errors, but in the production I got the error:

Unable to load application: TypeError: superclass mismatch for class Order.

I don't know why this error happens, and after consulting some documentation, I think the error comes from Puma's set :puma_preload_app, true - is it right?

How can I fix this error and preload_app always set to true?

Zoran
  • 4,196
  • 2
  • 22
  • 33
JeskTop
  • 481
  • 1
  • 4
  • 20
  • Is that actually what is in your files? Doesn't look like valid ruby at the moment to me – Frederick Cheung Jun 12 '15 at 08:31
  • Any particular reason `Chartable` is declared withing `Order`? – jcm Jun 12 '15 at 12:50
  • @FrederickCheung My files just like `model/concerns/order/chartable.rb` – JeskTop Jun 14 '15 at 06:31
  • @jcm Because `Chartable` only work in `Order`. – JeskTop Jun 14 '15 at 06:31
  • 1
    Is that the complete code? This [other question with the same error](https://stackoverflow.com/questions/9814282/typeerror-superclass-mismatch-for-class-word-ruby) happened because a class was defined twice with different superclasses. – jcm Jun 14 '15 at 07:07
  • @jcm I think it is not the same that question, because work find and no errors in the development environment. – JeskTop Jun 15 '15 at 06:22
  • This is most likely due to file load order. The class is probably first being defined from within the concern file. Then when the model file is loaded, I'm guessing the model inherits from ActiveRecord meaning that you are trying to add the inheritance after the class has already been defined. See this [answer](https://stackoverflow.com/questions/5512023/ruby-on-rails-3-superclass-mismatch-for-class#answer-9700350) – skukx Jun 06 '17 at 23:10

0 Answers0