I always have a problem parsing Rails‘ named routes in my head. It usually takes me a lot of time and effort to decide which controller action or view file is responsible for given path. Of course, it’s easy to tell when you look at:
that you probably should go to
users_controller.rb and find
edit action and
views/users/edit.html.haml is the right view file. But when nested routes, prefixes and non-RESTful actions all come to play, you might end up with a monster like:
Don’t laugh, this is real. So, what’s going on here? What is the action name? Are those “employer” things prefixes or nested routes? Where do I find the view? To answer all these questions, the Rails Routes TextMate bundle was born.
This is my list of TextMate‘s keyboard shortcuts that are very useful for Ruby and Rails developers, but are not used as widely as they should (according to my very scientific observation on a very representative sample, i.e. my colleagues). I skipped all the obvious ones (like “open file”, “save file”, “go to next window”, “close window” etc.) that most people use anyway. My list includes shortcuts that are very useful but sometimes might be hard to grasp at first or might require a little explanation.
Here’s a small TextMate tip I discovered today. Normally, some TextMate functions don’t work too well with Ruby code. Word selection and keyword completion ignore Ruby-specific characters like
!. For example, if you used somewhere method like
blank? and then you type
bl and press
Esc, TextMate will complete it as
blank, ignoring the
? at the end. And don’t even get me started about when you double click
blank? and the
? is not selected.
To change it, go to the Preferences (
CMD-,) and select Text Editing tab. At the bottom, there’s an editbox labeled Word characters containing a single
_ by default. Add characters
:?! to this editbox, close the window and you’re done. Enjoy!
There’s one caveat, however. This setting is global and affects word selection and keyword completion in all files. If you edit many other types of files, that could be a problem.
Recently I wanted to export some of my snippets from Textmate, so my teammates could use them too. I tried everything: right-clicking on snippets and bundles, clicking various buttons in Bundle editor, searching through menus and options, but I couldn’t any command for doing so. After several minutes of frantic clicking, I resorted to reading help file. To my surprise, exporting and importing bundle items is very simple, almost too simple.
If you want to share a bundle or particular bundle item then you can drag it directly from the bundle editor (from the list in the left side of the window) to the Finder.
This item can then be sent to other people and they will be able to double-click it to install it. Note: this also works for single items, like a snippet or a command.
Moral of the story: too much intuitiveness will kill you. Or: if you make something too simple, some people may overlook it. Maybe you should add a less intuitive option for them too (like right-click menu item).