ruby - When and where do I require files in a rails application? -


Assume that I have the following file in my lib directory of my Rail application:

  # Lib / proxy.rb module SomeService class ServiceProxy def do_something end end end  

If I want to use ServiceProxy in a model, I can use it like this: < / P> # app / model / product. Rb is known as 'Proxy' category product & lt; ActiveRecord :: Base Def do_something proxy = SomeService :: ServiceProxy.new Proxy.Do_Last End End

This works, but I think if I want to use serviceproxy in any other model I do not need it, then I do not need it. "Proxy Required" in the second model file "It appears that" in any model 'a proxy is required' it will add to the lookup path

Update: Based on Floyd's answer below, And my service process file was saved as such,

  # lib / some_service / service_proxy.rb  

Then I need to explicitly file

There is a useful post about this problem.

In short, the Rail Autoloads Classes only follow the appropriate naming conventions in your Lib Dirty.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -