This a very short note on setting up Capybara to correctly follow redirects with Rails classic
redirect_to @object pattern.
The problem why Capybara might not properly follow redirects in this case is that when
redirect_to is called with ActiveRecord object argument an
absolute URL is created and passed instead of relative one. So depending on the way of how Capybara server is started this might not work. To avoid this issue, one has to properly setup
app_host and Capybara server settings (
Here we use port
3002 for both port settings and Capybara redirects as expected!
Before you leave…
Would you like to learn how to deploy your own Ruby on Rails applications? I am writing a book for people like you.