Reputation: 2927
I have a nested module set up as a base helper method which is not getting included in the app that uses the engine.
in lib/mol/blog/blog.rb
require "mol/blog/engine"
module Mol
module Blog
module Categories
def self.included(base)
base.helper_method :categories
end
def categories
Mol::Cms::Category.all
end
end
end
end
In the engine's spec/dummy application_controller
class ApplicationController < ActionController::Base
protect_from_forgery
include Mol::Blog::Categories
end
This works fine and the categories appear as expected. However, when I try to use the engine in a different app, the Categories module is not being included.
in the app's application controller
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include Mol::Blog::Categories
end
In the rails console, the error is uninitialized constant Mol::Blog::Category (NameError)
Mol::Blog
is defined, no error or anything. Why is the Categories module not being recognised?
Upvotes: 0
Views: 756
Reputation: 7024
Your app does not know about Mol::Blog::Categories
module. You should require it in the "mol/blog/engine.rb"
file or in the "mol/blog.rb"
file.
# mol/blog.rb
require "mol/blog/categories"
module Mol
module Blog
# ...
end
end
Upvotes: 0