Skip to content

Instantly share code, notes, and snippets.

@zbeat
Forked from nuxlli/console.rb
Created August 23, 2017 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zbeat/cba3178c5e1eb10b0f36279d69a0f16f to your computer and use it in GitHub Desktop.
Save zbeat/cba3178c5e1eb10b0f36279d69a0f16f to your computer and use it in GitHub Desktop.
To access url helpers (url_for, etc) from Rails console (Rails 3)
# Example from: http://snipplr.com/view/37063/
include Rails.application.routes.url_helpers
# set host in default_url_options:
default_url_options[:host] = "localhost"
# can then use:
url_for()
# can check existing routes:
edit_user_url(User.first)
=> "http://localhost/user/1/edit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment