rails include route helpers in console
Open a Rails console by running
rails console
orrails c
in your terminal.Inside the console, load the application environment using
load "#{Rails.root}/config/environment.rb"
.Access the routing helpers by including the
Rails.application.routes.url_helpers
module with the commandinclude Rails.application.routes.url_helpers
.Now you can use the route helpers in the console. For example, if you have a route named
posts_path
for a resourceful route to display all posts, you can use it like this:posts_path
.