rails include route helpers in console

  1. Open a Rails console by running rails console or rails c in your terminal.

  2. Inside the console, load the application environment using load "#{Rails.root}/config/environment.rb".

  3. Access the routing helpers by including the Rails.application.routes.url_helpers module with the command include Rails.application.routes.url_helpers.

  4. 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.