Rails 2.x: load custom task defined in a gem

Hello,

I'm writing a nice gem which incorporate a few rake tasks, but I can't
find a way to add my custom tasks to the application rake list, if the
app is rails 2.x. I googled for a while but without any luck... any
hints?

Thanks

Andrea

Hi,

For new custom rack task you have to write rake file under the location
Project/lib/tasks/sample.rake

In that sample.rake file

desc "This task is back-end ruby script added for cron job"
task :cron => :environment do
# put some logic.
end

Go to your console put the command #> bundle exec rake -D

It will return rake tasks which are used in your project.

For example, here you will get your task

rake cron
    This task is back-end ruby script added for cron job

Run it using #> bundle exec rake cron

andrea longhi wrote in post #1053442: