Calling a controller from the Rails console

Fire up your console:

rails c

then:

app.get ‘/posts/1’

response = app.response

response.body # if you need the HTML body

response.cookies # if you want a hash of the cookies

Plenty more here:

http://rails.rubyonrails.org/classes/ActionController/Integration/Session.html

and here:

http://stackoverflow.com/questions/151030/how-do-i-call-controller-view-methods-from-the-console-in-rails

However, if you want to do some serious debugging you’ll probably want to use pry. See an earlier post.

Leave a Reply

Your email address will not be published. Required fields are marked *