2021年5月5日星期三

Modules not loaded on production server

I have a problem because my code does not work on the production server. When it comes to development environment, everything is fine. It looks like he doesn't read the classes. My ruby version is 2.6.6 and rails is set as 5.2.4.4.

lib/crm/api.rb

module CRM    class API      # some code    end  end  

app/services/crm/changes.rb

module CRM    class Changes      def initialize        @api = API.new      end      # some code    end  end  

The main service is running as a cronjob.

config/schedule.rb

every 5.minutes do    runner('CRM::CheckChanges.new.call', output: "#{path}/log/crm_check_changes.log")  end  

And run this code

app/services/crm/check_changes.rb

module CRM    class CheckChanges      def initialize        @changes = Changes.new      end      # some code    end  end  

At first I got errors log like 'Uninitialized constant CRM::Changes::API' after reload background jobs I got 'Unitialized constant CRM::API'

config/application.rb

config.autoload_paths += %W(#{config.root}/lib)  config.autoload_paths += %W(#{config.root}/app)    Dir.glob(Rails.root.join('lib/**')).inject(config.autoload_paths){ |autoload_paths, path| autoload_paths << path }  

As I mentioned before everything works fine on development environment. Does anyone have any idea what this could be about? Thanks in advance for answer.

https://stackoverflow.com/questions/67406101/modules-not-loaded-on-production-server May 06, 2021 at 01:30AM

没有评论:

发表评论