Use Controller Via Routes in Rails Console

If you need to hit a route from your Rails console and see the output you can use the following pattern.

app.get '/posts/1'
response = app.response

You now have a rails response object much like the integration tests.

response.body # get you the HTML
response.cookies # hash of the cookies
response.header # you get the idea

Leave a Comment