← Back to Upcase

Undefined constant error when using 'include' inside rails engine


(Shankar Dhanasekaran) #1

Hi I’m writing a rails engine and added the_sortable_tree as a dependency.

My controller looks like this

module KB
  class AccountsController < ApplicationController
    include ::TheSortableTreeController::Rebuild
  end
end

However this throws error “uninitialized constant TheSortableTreeController”. How do I resolve this?

But if I use the_sortable_tree gem in a normal rails project which is not nested in a module, it works perfectly fine. So I dont think it’s a problem with the gem, rather, my understanding of including inside a module.

This works fine.

class AccountsController < ApplicationController
  include TheSortableTreeController::Rebuild
end