Skip to content

Instantly share code, notes, and snippets.

@ilake
Created March 10, 2010 16:10
Show Gist options
  • Save ilake/328011 to your computer and use it in GitHub Desktop.
Save ilake/328011 to your computer and use it in GitHub Desktop.
$ ruby script/console
>> app.url_for :controller => :public, :action => :about
=> "http://example.com/public/about"
>> app.get("/public")
=> 200
>> app.get("/ryan")
=> 404
# others include
>> app.response.headers
>> app.response.body[0,75]
>> app.post("/collection/add/1")
>> app.response.redirected_to
>> app.follow_redirect!
# fix errors in your code, then...
>> reload!
#=====================
>> irb ActionController::Routing::Routes
>> puts routes
ANY / {:action=>"index", :controller=>"public"}
...
ANY /:controller/:action/:id.:format/ {}
# independently play with paths
>> recognize_path "/about"
=> {:controller=>"public", :action=>"about"}
>> recognize_path "/public"
=> {:controller=>"public", :action=>"index"}
# or check a path inversely
>> generate :controller => "public", :action => "about"
=> "/about"
>> generate :controller => "public", :action => "index"
=> "/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment