Heroku, cron.rake and friendly_id gem
I'm using the friendly_id gem. There's a rake task for deleting old slugs (from the docs):
rake friendly_id:remove_old_slugs MODEL=<model name> DAYS=<days>
It can be run via cron.
Do you know how it should be added to cron.rake (I'm on Heroku)?
Here is my cron.rake:
desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
...
rake friendly_id:remove_old_slugs
end
It produces an error:
"rake aborted! undefined method `friendly_id' for main:Object"
There is no error if I ru开发者_C百科n it from the console (Terminal) like this:
heroku rake friendly_id:remove_old_slugs
Try this:
desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
Rake::Task['friendly_id:remove_old_slugs'].execute
end
精彩评论