DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Firing A Controller's Action From The Console
It seems like a simple task, but here's how you can simulate the calling of a controller's action:
ruby script/console irb> require 'action_controller/test_process' irb> require 'application' irb> require 'site_controller' irb> request = ActionController::TestRequest.new irb> response = ActionController::TestResponse.new irb> request.env['REQUEST_METHOD'] = 'GET' irb> request.action = "late_employee" irb> InfoController.process(request,response)
Basically, it's like getting inside of a TestUnit method, but you have to do the dirty work yourself.