vn81ha
Last Updated: July 08, 2016
·
2.015K
· ometa
F1fc0686524f09c0be19ea87d5e93cd4

Rake task to call a Rails controller method

Here's a Rails rake task that calls a particular endpoint without having to actually call a worker like unicorn.

namespace :controller do
  desc "Call the package endpoint"
  task :package => [:environment] do
    app = ActionDispatch::Integration::Session.new(Rails.application)
    app.get "/package"
  end
end
Say Thanks
Respond

1 Response
Add your response

27848
None

Thanks for this. When running I get
NoMethodError: undefined methoddebug' for nil:NilClass`
Any idea why?

over 1 year ago ·