开发者

Heroku, cron.rake and friendly_id gem

开发者 https://www.devze.com 2023-03-09 04:26 出处:网络
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>

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
0

精彩评论

暂无评论...
验证码 换一张
取 消