vn81ha
Last Updated: July 08, 2016
·
2.962K
· ometa

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

1 Response
Add your response

27848

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

over 1 year ago ·