Posted By

insanedreamer on 07/10/10


Tagged

testing rails rails3


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

TaopaiC


To access url helpers (url_for, etc) from Rails console (Rails 3)


 / Published in: Rails
 

in Rails 2, use include ActionController::UrlWriter instead.

  1. include Rails.application.routes.url_helpers
  2.  
  3. # set host in default_url_options:
  4. default_url_options[:host] = "localhost"
  5.  
  6. # can then use:
  7. url_for()
  8.  
  9. # can check existing routes:
  10. edit_user_url(User.first)
  11. => "http://localhost/user/1/edit"

Report this snippet  

You need to login to post a comment.