Friday, July 11, 2008

Need access to your Rails Url generation methods in a script/runner script?

In script/console you can access url_for, named route url generation methods, and restful url generators using the app variable. It works like so:

>> app.url_for(:controller => "home", :action => "index") => "http://www.example.com/home"

That is great. But what if you need to do that in a script that you want to run using script/runner? It turns out that is easy too. You just need to require 'console_app' (in Rails 2.*) like so:

require 'console_app'
7/11/2008 11:17:11 PM (Central Standard Time, UTC-06:00)  #    Trackback


Links

Categories

Archives