In my rails 4 app, I have a subfolder logic
in my App folder, where I put classes/methods that don't belong to controllers or models.
However, when I try to access these methods from a controller, I get an unknown method error.
Here is a class in the logic
folder:
class Analyze
def intent_determination(msg, context)
keywords = [["categories", "category"], ["brands", "brand"], ["stock", "stocks"], ["info", "information"], ["no"], ["yes"]]
tokenized_array = msg.split
keywords.each {|array| context["intent"] = array.first if (tokenized_array & array).any? }
context
end
def update_context(msg, session)
session.update(context: intent_determination(msg, session.context))
session.update(context: brand_determination(msg, session.context))
session.update(context: style_determination(msg, session.context))
session
end
end
How can I access these methods in my controllers ?
When I just execute update_context(my_message, @session)
, as I said, I get an unknown method error.
Here is my App folder structure:
App
Assets
Controllers
Logic
analyze.rb
Helpers
Mailers
Models
Views
EDIT:
I did add:
config.autoload_paths << Rails.root.join('app/logic/**/')
to my application.rb file.
So this is not a duplicate.