Where should I place my own "module" within rails application? -
Certain functionality looks better in my Rail application as if it was a different "module", which is
is required. For example, suppose it is a function to calculate the Fibonacci numbers.
The functionality is free on the rail application and can be reused in other projects, so this app should not be stored near the controller and the model, I think but since I did it in separate projects I'm not going to separate, so this does not look like the right thing by putting it into the seller
folder.
Where should I put it then?
Instead of placing the reusable code as if it is in the lib
directory You do not already have a requirement in the form of need
in the form of lib
and its contents will be loaded in the initial time.
If you expand an existing class, you first define your module and then include it by sending that class as a message, which you want to extend, e.g.
Module MyExtensions def self.included base base.instance_eval def my_new_method ... end end end end ActiveRecord :: Base.send: included, MyExtensions