I have a module and a child class. Where i have all the functionality inside the module. and inside the child class I just call the methods from the module. I want this module to be linked with a rake task under a namespace, and these two files are in the same directory. RAILS_ROOT/lib. How do I do this? I am running Rails 3.0.3.
create a file under lib/tasks/your_namespace.rake , and write the task:
namespace :your_namespace do
desc "An optional description of your task"
task :your_task_name => [:environment] do
# your code stuff
end
end
you should be able to use code from modules. In case, just add this line in rake task:
require 'yourfile'
You need to both require and then include:
require 'your_module'
namespace :your_task do
include YourModule
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With