InquiryLabs

Politics, Programming and Possibilities

Rails Cheat Sheat for TextMate

Now that the syncPEOPLE on Rails bundle is built in to TextMate by default, it would be nice to see the commands, macros and snippets all in one sheet. It looks like Sebastian Friedrich beat me to it—take a look at his TextMate Rails PDF.

Thanks, Sebastian!

syncPEOPLE on Rails 1.0

Just a little note to say the syncPEOPLE on Rails Bundle for TextMate has reached 1.0 and is ready for download. Visit the syncpeople.com downloads page for links.

There is now a demo video available (low-bandwidth version here).

It’s been several years since I’ve had the desire to invest time in a computer game. In fact, I haven’t really seen an original game in 15 years. But Spore looks to be out of this world.


Take a Look at the Spore Gameplay Demo Video

  • 1 Comment
  • Filed under: Life and Family
  • Finding a Screencasting Tool for Mac OS X

    It’s taken me a suprisingly long time to find a decent screencasting / screen recording tool for Mac OS X. I tried SnapZ and didn’t like the complexity. Nor the price.

    vnc2swf is an interesting and free option, but it doesn’t come with built-in sound recording, and I couldn’t find a shell-based alternative to the linux-only arecord alsa audio recording tool. In addition, the coupling between OSXvnc and the recording tool means you need to change the resolution of your screen using the pref pane to 800×600 if you want to make browser-friendly screencasts. That made things feel a little crunched on my 20″ iMac.

    So what other options are there? The most comprehensive list I could find was at answers.com. In the end, I chose ScreenRecord, due to its simplicity and fair price: I’m willing to shell out $20 for this.

    Auto-fill Reverse Migration

    Kyle Maxwell tipped me off to the lunchbox blog where Scott Barron wrote about an “auto-fill reverse migration” command for TextMate.

    Unfortunately, Scott lost his work in a hard drive crash a while back, so I wasn’t able to use his work. But I did steal his idea! In the latest syncPEOPLE on Rails bundle (now in the TextMate Bundle repository) you can use the “Migration Drop and Create Table” macro/snippet combination.

    Basically, what happens is since it knows you’re trying to drop a table, it uses your schema.rb file to figure out how to re-create the table for your migration’s self.down method. All in one context-sensitive snippet triggered by “mdct[tab]“.

    Need to Upgrade Rake for Edge Rails

    For anyone not following the discussion on the rails dev mailing list, you’ll need to upgrade to Rake 0.7.0 to use any of the standard ‘rake’ commands from now on. An error message that you might get without upgrading, for example, would be:

    [duane@mail1 socialconference]$ rake -T
      (in /home/www/socialconference)
      rake aborted!
      undefined method `namespace' for main:Object
      ./Rakefile:10
    

    So go on and ’sudo gem update rake’ or whatever it is you do to upgrade your gems under your environment and get those namespaces in to rake!

    More Fixes and Some Forgotten Files

    I meant to include Sami Samhuri’s Snippets and Macros in the last release—and, unfortunately, did so in a half-baked manner. In this release, the snippets and macros are all there, and they sure are cool! Thanks, Sami.

    Enter Key Deprecated

    Some people asked about the enter key that was bound to the Intelligent Go To File command. Please note that the enter key will no longer be bound to this command by default. See my earlier post for more information on why this key was split in to two commands. Use ⌘⌥↓, bound to the “Go To File” command and ⌘⌥↑, bound to the “Go To File on Current Line” command instead. I’ve included the older (combined) Intelligent Go To File command in the library, but this time I’ve not bound it to any keys.

    Download

    As usual, please let me know if you find anything amiss.


    Download the Disk Image
    TextMate Rails Bundle 1.0 RC4

    Rails Bundle for TextMate 1.0 RC3

    New Way of Accessing Ruby

    My friends on IRC have helped me track down and understand better the way TextMate helps its bundles by setting up the environment for Ruby code. The Rails bundle now uses the TM_RUBY environment variable to determine which ruby on your system to use (i.e. if you have multiple ruby shell commands installed).

    One of the biggest problems with this environment stuff has been trying to figure out the best way to support all of the many ways you can get Ruby on your system: the built-in version patched with fixrbconfig, DarwinPorts, your own version, or perhaps even Locomotive’s ruby-in-a-box. For those of you who’ve been experiencing problems with past versions of the Rails bundle, I think this one may fix it for you. If you’re still having problems, try adding a TM_RUBY environment variable to your TextMate shell variables (in Preferences, go to Advanced, then Shell Variables). Point TM_RUBY to the location you installed ruby at.

    As usual, please feel free to contact me and we can try to work out a solution if you’re still having trouble. Comments showing your problems or solutions are also welcome.

    Download


    Download the Disk Image
    TextMate Rails Bundle 1.0 RC3

    Rails Bundle for TextMate 1.0 RC2

    Changes

    Looks like RC1 didn’t get some of the updated textmate_footnotes plugin code. This release candidate includes the newest testmate_footnotes, and also attempts to fix some issues people have been experiencing with ‘command not found’ and other PATH-related problems. Let me know if we’re getting any closer for those of you having these issues.

    UPDATE: Looks like I’m still learning a few things. The folks on IRC tell me that adding the .profile is a very bad thing, so I’m going to have to try to solve this in another way. Download and try if you’d like, but wait for another release if you’re paranoid :)

    Download


    Download the Disk Image
    TextMate Rails Bundle 1.0 RC2

    It’s official, folks!

    After talking with my partner, Greg Narain, as well as Allan Odgaard, the creator of TextMate, we (syncPEOPLE) have decided to release our Rails bundle under the MIT license so that it can nest itself nicely within its new home, the TextMate Subversion Bundle Repository. If you have subversion set up with TextMate, update your bundles and you’ll get it all.

    What this means for the rest of us is that all of these great features we’ve been madly developing are going to be available as the default Rails bundle when the next version of TextMate is released. Thanks to all who’ve contributed to this work already. Keep it up!

    Changes in the 1.0 Release Candidate

    There are some major key binding changes in this release, due to my own slow but steady understanding of TextMate conventions and the evolving complexity of making this intuitive. Bundle keys are normally bound to the ctrl-shift combination, not the command-option combination. Therefore, in following with this convention, the new bundle uses the following bindings for its commands:

    • ⌘⌥↓: Intelligent Go To File
    • ⌘⌥⇧↓: Show “Go To File” Choices
    • ⌘⌥↑: Go To File on Current Line
    • ⌃⇧” (without selected text): Inline Partial Edit Mode
    • ⌃⇧” (with selected text): Create Partial from Selection
    • ⌃⇧\: Call Generator Script
    • ⌃⇧\: Install Plugin

    The Enhanced TODO List has been moved to the TODO bundle itself, so everyone (Rails and non-Rails folks alike) will benefit from it. It will be updated soon.

    New Language Scoping

    In order to create the “Show Go To File Choices” command and its list of choices, I created some new language scoping rules in TextMate that may prove interesting in the future. Basically, there are 6 new scopes available for Rails bundle creators to play with:

    • meta.rails.functional_test
    • meta.rails.controller
    • meta.rails.helper
    • meta.rails.mailer
    • meta.rails.model
    • meta.rails.unit_test

    What this amounts to is that you can bind certain snippets, commands or macros to specific scopes within the rails project. For example, suppose you want to create a macro that adds scaffolding code to your controller. With the new scopes, you can bind your command to meta.rails.controller and rest assured that you won’t accidentally add scaffold actions to your model. In addition, this new scoping allows you to bind multiple commands with the same key binding to a single scope to create a pop-up menu with choices. Try ⌘⌥⇧↓ to see this latter benefit in action.

    What About the ‘Keypad Enter’ Key Binding?

    After some discussion, we (Allan and I) decided to remove the keypad enter binding and replace it with the ⌘⌥↓ key combination. There were a number of reasons for doing this:

    • ⌘⌥↓ has been bound to a similar function, rails-open-partner, for some time already.
    • The keypad enter key doesn’t work on PowerBooks and iBooks without some tweaking.
    • The keypad enter key is already bound to a global next-line action.

    With that said, however, there’s certainly nothing stopping you from re-binding the enter key to your Rails bundle. If it works for you that way, great!

    Final Words

    I’ve put a lot of work in to making this release a much more robust, refactored release. There are some really handy classes that have been created just for TextMate (included in the bundle) that I’d like to mention for the benefit of other bundle makers:

    1. TextMate Module: Namespace module for message functions, opening text files in textmate, and exiting with special exit codes that TextMate understands.
    2. Buffer Class: Reads in a text file and provides search functionality as well as state information (such as current line and current column number).
    3. RailsPath Class: Understands the Rails app directory structure and provides a way to easily swap between associated files. For example, calling rails_path_for(type) on a controller file will pass back the full path (wrapped in a RailsPath object) of any associated helper file or functional test file.
    4. UnobtrusiveLogger Class: Use $logger.debug “(your message here)” to send output to ~/textmate_bundle.log.
    5. String Class Modifications: See misc.rb for mods to String

    Get it now!

    If you don’t use the subversion repository, download the new Rails bundle as a Disk Image here.


    Download the Disk Image
    TextMate Rails Bundle 1.0 RC1