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
Written by Ometa
Related protips
1 Response
Thanks for this. When running I get
NoMethodError: undefined method
debug' for nil:NilClass`
Any idea why?
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#