2

I currently have this folder directory

  1. app
    • controllers
      • project_controller.rb
      • subtasks
        • index_helper.rb

project_controller.rb

class ProjectController < ApplicationController
  include Subtasks::IndexHelper

index_helper.rb

module Subtasks::IndexHelper
....

This configuration works locally without a require statement. But when run on a CI (semaphoreci) it returns

ActionController::RoutingError:
        uninitialized constant Subtasks::IndexHelper

I've tried to use the autoload function by adding all possible sub-configurations of

    config.autoload_paths.push "#{config.root}/app/controllers/subtasks"

but this throws a different error

Failure/Error: include Subtasks::IndexHelper

LoadError:
Unable to autoload constant IndexHelper, expected 
/home/runner/app/controllers/subtasks/index_helper.rb to define it

My Question is: Is there any way to include this module without any require, require_relative, require_dependency clauses? This setup worked a couple months back, but it all of a sudden started failing.

Max
  • 23
  • 4
  • do you need to manually add `subtasks` to the autoload paths, they are inside `app` so they should be loaded by rails – Subash Jul 26 '18 at 00:30
  • This isn't being autoloaded because it's not named correctly. https://guides.rubyonrails.org/autoloading_and_reloading_constants.html – Josh Brody Jul 26 '18 at 00:36
  • 2
    Have you tried the nested format for your module? i.e. https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#nesting – supremebeing7 Jul 26 '18 at 02:52
  • I've tried nesting, but it returns LoadError: Unable to autoload constant IndexHelper, expected /app/controllers/subtasks/index_helper.rb to define it. But it's clearly defined? – Max Jul 26 '18 at 18:58

0 Answers0