Skip to content
A TextMate bundle with a couple of navigation functions for Rails' named routes: go to action, view etc.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Commands
Support/lib
.gitignore
README.rdoc
info.plist

README.rdoc

This is a TextMate bundle that provides a couple of functions for working with Ruby on Rails' named routes. The functions currently are:

  • go to named route action or view – Cmd-P

  • go to named route action – Ctrl-Cmd-P

  • go to named route view – Opt-Cmd-P

  • go to routes.rbCtrl-Opt-Cmd-R

Usage

If the selected text (or word under cursor) looks like a named route expression in your controller or view code, e.g:

edit_user_path(@user)
root_path
post_comment_url(@post, @comment)
new_publisher_magazine_photo_url

you can press Cmd-P to go to the action or view associated with this route (the choices are presented in a popup menu). You can also press Opt-Cmd-P to go directly to the view file or Ctrl-Cmd-P to go directly to the action.

Installation

mkdir -p ~/Library/Application\ Support/TextMate/Bundles
cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://github.com/szeryf/rails-routes.tmbundle.git
osascript -e 'tell app "TextMate" to reload bundles'

Troubleshooting

Normally when you press any of the shortcuts, you should see a progress bar saying “Loading routes.rb” for a moment (exactly how long depends on your project and routes.rb size). If it says “Loading environment.rb” instead and stays considerably longer, there may be a problem with your routes.rb depending on something that is loaded by environment.rb file (in one of my projects it was a config class). So, if you want to speed up these operations, make sure that your routes.rb can be required without requireing environment.rb first (which takes notoriously long in most Rails projects).

To check this, run irb (NOT script/console) in your project directory and try issuing the following:

>> require 'config/boot.rb'
=> true
>> require 'action_controller'
=> true
>> require 'config/routes.rb'
=> []

If this goes without errors, you should be good to go. If you get some errors, there is something missing for routes.rb. You'll have to examine those errors and fix them if possible.

Compatibility

Tested with Rails 2.3.5. Should work with any Rails 2.x version (if it doesn't let me know). May not work with Rails 3 (I haven't tested it) but patches welcome.

To do

  • a command to go to route definition inside routes.rb

  • action names in menu for controller

  • separate menu sections for views, controller, route definitions

  • make it faster (somehow cache the routes?)

Something went wrong with that request. Please try again.