Dr Nic

Get ready for the TextMate “Trundle to Rails 2.0 Bundle”

logo_bundle.png

Have you noticed lately that the Rails TextMate git pull origin two_point_oohbundle (also installed with e – the Text Editor for Windows) isn’t quite as helpful as it once was – guiding and amplifying your rails app development.

Your resourceful/restful rails apps are now filled with named routes, but none of the helpers (link_to, redirect_to, etc) use them. The default view template was still rhtml for a long time (latest svn trunk fixes this to be html.erb, though Marc Jeanson is having a crack at supporting both through a per-project config file).

Or perhaps you were hoping for some snippets for new features of Rails 2.0: assert_difference (asd), assert_select (ass), respond_to (rst).

Or just maybe, you’ve been updating your local bundle to Rails 2.0 already? Please say yes, please say yes. If you are saying “yes”, read at the bottom for how/where to send me the patches. If you are saying “no”, read at the bottom for how/where to start creating patches and sending them to me.

Firstly, DHH didn’t write the Rails bundle

I didn’t know this – I just assumed the guy who created Rails and helped promote TextMate also created the Ruby on Rails TextMate bundle. Instead if was WWF’s “The Rock” himself Duane Johnson (figurines sold separately, and may look different to the real Duane Johnson who writes Rails code instead of prancing around in his underpants with other adult males in confined spaces).

The TextMate SVN logs say that it the bundle was first committed in Jan 2005. Its now Jan 2008. That’s three years of maintaining a suite of code that thousands of people take for granted every day writing Rails code. What a champion.

Like the Australian Cricket team’s wicketkeeper, Adam Gilchrist, he’s also retiring at the top of his game.

New Maintainer… me

Instead of maintaining my own projects, I’ve decided to maintain this one. I love the TextMate bundles. Before I had a Mac, I ported them across to RadRails and many RadRailers entered a golden era of snippet happiness.

My bundle-fu may not be the equivalent of Bruce Lee, but I’m keen to see my favourite Rails tool live on strong.

Bleeding edge bundle

Whilst the TextMate SVN administrators process the maintainer change request (Allan is on holidays somewhere and he took the house keys with him), you might think all is lost!

Never.

The straight-off-the-cow bleeding edge Rails bundle can be accessed via Git. Specifically the branch two_point_ooh.

So, let’s all do away with our pre-existing Rails bundle and live on the edge.

cd ~/"Library/Application Support/TextMate/Bundles/"
mv "Ruby on Rails.tmbundle" "RoR.tmbundle.orig"
git clone git://github.com/drnic/ruby-on-rails-tmbundle.git "Ruby on Rails.tmbundle"
cd "Ruby on Rails.tmbundle"
git checkout --track -b two_point_ooh origin/two_point_ooh
git pull

Now, back in TextMate, go to menu “Bundles” > “Bundle Editor” > “Reload Bundles”.

You, my friend, are sitting pretty.

Upgrading to when newer blood is on the bleeding edge

Coming back for more?

cd ~/"Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle"
git checkout two_point_ooh  # optional; only if you changed to another branch etc
git pull

Now, back in TextMate, go to menu “Bundles” > “Bundle Editor” > “Reload Bundles”.

Bathe yourself in glory. Splash it all over yourself.

Submitting patches

If you go into TextMate, launch the Bundle Editor (Cmd+Alt+Ctrl+B) and change something in the Ruby on Rails bundle, then files will added/changed within your local git clone.

What I mean is, you can very simply submit patches now. [When I say "simply", I mean, "I think this is the best approach but I could be completely wrong here..."] Git is so cool that I don’t know what its doing most of the time; but let’s hang in there as a team.

cd ~/"Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle"
git add .   # to add any new files/snippets/commands you created; TextMate uses one file per snippet
git commit -a -m "Useful message about this patch goes here"
git diff -p HEAD^ HEAD

[Theoretically] this creates a patch based on your most recent commit. So you can easily create patches for changes even if your repository and the remote/central/bleeding edge repository look different.

If your patch was created over several commits, then replace HEAD^ with HEAD~4, if there were 4 commits.

I think. God I could be wrong about this though.

Just try your best and if it works, let me know and I’ll remove all this “I don’t know what I’m talking about” text and future readers will think I know everything. Web 2.0 rocks.

Send patches to…

Me drnicwilliams@gmail.com [update] or via the new Google Group.

Update: Note there is a new Google Group (rails-textmate) created in Feb 2009 due to Spam and loss of admin control on original group.

Want to fork the git repo? Use a free account at Gitorious or GitHub.

Google Groups
Ruby on Rails: TextMate
Visit this group

Trundle to Rails 2.0 Bundle

Arguably, we just keep patching the bundle forever and bleeding edges will continue to live happily within the blood and muck of said existence.

But, lots of other people want nicely zipped up bundles. No doubt “e – the Text Editor” will want a “released” version so they can clean it of all the ugly things they can’t yet replicate like Macros. And eventually I’ll push it all down to the SVN repo and it will be released with future TextMate upgrades.

So, there will be a “Rails 2.0 compatible” grand opening one day soon. Probably before 14th of March 2008, when I’m giving a “What’s new in Rails 2.0?” talk at QCON London. Showing off the new bundle will be sweet.

That gives us 6 wks to refactor this bundle to make it a shining example of all that is wonderful in Rails 2.0. Every patch helps.

[Please consider Rails 1.2.6 and before developers when conceiving of patches, and please consult your doctor if pain persists.]

Related posts:

  1. Instant new Rails applications with the App Scrolls When I start a new project I want to start...
  2. Packaging TextMate bundles in OS X DMGs Last week Engine Yard released a CLI for their Engine...
  3. Validate and Save your Ruby in TextMate – with secret Rubinus superpowers In some TextMate bundles, if you save a file it...
  4. Using CoffeeScript in Rails and even on Heroku I’m pretty excited about CoffeeScript as a clean-syntax replacement for...
  5. First look at rails 3.0.pre This article is out of date in some aspects....

62 Responses to “Get ready for the TextMate “Trundle to Rails 2.0 Bundle””

  1. Ilya Sabanin says:

    I trying to clone repo using your command (git clone git@github.com:drnic/ruby-on-rails-tmbundle.git “Ruby on Rails.tmbundle”) but it keep asking me password.

    I use Git version 1.5.3.1

  2. Dr Nic says:

    oops, sorry – I pasted the wrong git url.

    Try git clone git://github.com/drnic/ruby-on-rails-tmbundle.git "Ruby on Rails.tmbundle"

    Sorry about that

  3. Ruby says:

    Nic,

    You also forgot the step of cd “Ruby on Rails.tmbundle”
    between the git clone and the git checkout

  4. To create the patch that I sent you I used:
    git-format-patch

  5. lawrence says:

    Holy waves of bliss, I’m bathing alright! Love you, mean it, great hair, hope you win!

  6. It’s no longer detecting file types for me in rails… hrm, I must have changed something else, maybe?

  7. lawrence says:

    btw, isn’t the whole point of git that now anyone can maintain the bundle… instead of sending drnic patches, consider commiting to your own branch, make it public, possibly hosted by github.com. Then drnic can pull from there if he likes. That way everyone gets to see the patches you created, instead of only drnic. Perhaps drnic doesn’t quite like what you do, and therefor doesn’t include it in his master branch, but who knows, maybe a band of others do like what you’ve come up with… no problem, we just pull it in and merge it in our own branch.

    PS. I’ve send you a patch drnic ;)

  8. Dr Nic says:

    @Ruby [via] – thx fixed

    @Nathan Sutton [via] – weird. um. not sure why that might have happened. I’m a ex-Windows user so I suggest you do a reboot… :)

  9. Dr Nic says:

    @lawrence [via] – that’s all true; I’m not sure how easy it easy to get github accounts, nor how many people have setup public repos for me to pull from, so it might be an adoption hurdle.

    But yes, if anyone runs a public clone on github or gitorious or elsewhere, and has goodies, let me know.

  10. Dr Nic says:

    Perhaps it other people do start forks, we can add a FORKS file of repos.

  11. cool stuff, note that some people might find their “Ruby on Rails.tmbundle” in ~/Library/Application Support/TextMate/Pristine Copy/Bundles

  12. Dr Nic says:

    @Matt Aimonetti [via] – I think no changes ever made to the Pristine Copy, so if that’s your only copy of the Bundle, any changes you make are added into the Bundles area, not onto the Pristine Copy. Makes patching a little harder, but if you’re not using an SCM, its the way to go to manage local changes. [that is, it was built that way]

  13. johan says:

    There’s also an updated git bundle here http://gitorious.org/projects/git-tmbundle for textmate, for those who’re into that sort of thing

  14. Dr Nic says:

    @johan [via] – oh this gives some nicer outputs now. Cool.

  15. macournoyer says:

    ooooh a Git TM bundle ^^, I’ve been dreaming of this for days.

    And an updated Rails bundle.

    Is this christmas?

  16. Ben says:

    Excellent! Thanks, Dr Nic – and @johan! I’m the happiest guy in … well, my office, at least.

  17. [...] in good open source manner, the maintainership is being passed on to one Dr. Nic Williams of Australia (he’s a good guy, you’ll like him). Thanks to Dr. Nic, we should be seeing [...]

  18. Dr Nic says:

    As a special treat from the makers of GitHub – if you contribute to the TM bundle, you can have a beta GitHub account so you can easily fork my repository and I’ll pull your changes from there (instead of sending patches).

    Of course there is also the free Gitorious by famous Norwegian explorer Johan Sørensen.

  19. [...] Get ready for the TextMate “Trundle to Rails 2.0 Bundle” – Dr. Nic takes over maintenance. [...]

  20. Thanks for that! I mean, a lot.

  21. Awesome! I am so glad you took this over Nic. I have been hacking away at my bundle since 1.2.1 to get things to work properly and add all the cool new stuff and color formatting.

    I’ll get some changesets ready for ya! :)

  22. Josh Nichols says:

    You might want to quote the file path for the line:

    cd ~/Library/Application Support/TextMate/Bundles/

    Otherwise, it tries to cd into ~/Library/Application.

  23. Dr Nic says:

    @Josh Nichols [via] – thx, fixed.

  24. For patches, another nice option is git format-patch -n where n is the number of commits to make patches for.

  25. [...] Get ready for the TextMate “Trundle to Rails 2.0 Bundle” [...]

  26. [...] Bundle Editor (here and here). A better option is the new TextMate Rails 2.0 bundle now under development by Dr Nic Williams. Right now, it’s only available for download using git but maybe by the time you read this it [...]

  27. Anonymouse says:

    How about hosting it on SVN — essentially the STANDARD RoR repository, instead of fucking git?

    Why the fuck should I have to download git just to get an updated copy of the rails 2.0 bundle. Come on, man.

  28. Dr Nic says:

    @Anonymouse [via] – when the large changeset is initially done it will be committed to the SVN repo in one patch. The Rails 2.0 upgrade was done outside of SVN to ensure we never broke the SVN repo version for Rails 1.2 apps.

    Please ask questions politely though if you can.

  29. marcin says:

    I think preparing a cheat sheet for this will be good idea.

  30. gohanlon says:

    You can also execute this command instead of manually telling TextMate to reload bundles: osascript -e 'tell app "TextMate" to reload bundles'.

  31. Paul says:

    This does not work:

    cd “~/Library/Application Support/TextMate/Bundles/”

    Quoting the ~ prevents the shell from expanding it. Do this instead:

    cd ~/”Library/Application Support/TextMate/Bundles/”

  32. Dr Nic says:

    @Paul [via] – thx, fixed

  33. bondibox says:

    I’ve tried with the default Ruby on Rails bundle that came with TextMate, as well as this new bundle with 245 items. Even though I can see the Rails bundle available in the bundle editor and all the drop down GUI commands work for it, CTRL-CMD-T does not list the Rails bundle items and the key equivalents don’t work. I installed the RSpec bundle in the same location and it works o.k.

  34. Dr Nic says:

    @bondibox [via] – the items shown in the CTRL+CMD+T popup depend on the scope where the cursor is. So first, it requires you have a document open, and then it depends on the “language” or “syntax” that you select for that document. By default, a *.rb file might be allocated Ruby or “Ruby on Rails” syntax; but you can manually change it with SHIFT+CTRL+ALT+R and select “Ruby on Rails”. The CTRL+CMD+T popup should work for you then.

  35. James Wigs says:

    Excellent; for some reason the TextMate folder was missing in Application Support, as I have only used bundles that were included in the base installation (that were oddly not added to the Application Support folder…).

    Debugged using Command-R was throwing errors because of use of Ruby 1.2.6; this bundle was the perfect solution.

    So – for others who may have this problem, I just created the required folders (/TextMate/Bundles) and ran through the commands (mv didn’t work obviously) and all is working fine, so fresh!

    Thanks for the maintenance of this bundle – making things much easier :)

    James

  36. jOe says:

    I am receiving the below message when I attempt to perform a simple tasks, such as creating a view via the navigation menu:

    /Users//Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle/Support/lib/rails/text_mate.rb:54:in ‘method_missing’: undefined method ‘rescan_project’ for TextMate:Module (NoMethodError)
    from /Users//Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle/Support/lib/rails/command_go_to_file.rb:15:in ‘alternate’
    from /Users//Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle/Support/bin/go_to_alternate_file.rb:13

    The new file eventually displays within the tree. Any help would be greatly appreciated.

    Thank you,

    jOe

  37. Deke says:

    The link to http://groups.google.com/group/rubyonrails-textmate doesn’t seem to be working. I am following along on the peepcode textmate tutorial and when I select a div to turn into a partial, then press shift, control, H, it creates the partial, but in the show.html.erb I get the error:

    /Users//Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle/Support/lib/rails/text_mate.rb:54:in `method_missing’: undefined method `rescan_project’ for TextMate:Module (NoMethodError)
    from /Users//Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle/Support/bin/create_partial_from_selection.rb:46

    Any ideas?
    Also, when I went to ~/Library/Application Support/. There was no TextMate directory. I found a TextMate directory at Users/username/Library/Application Support/Textmate. but there was no Bundle directory so I created one and ran the git command from there. Was that the correct thing to do? I’m afraid I’m a bit of a noob when it comes to all of this. I’m a .Net developer whose seen the light.

  38. Dr Nic says:

    @Deke – there is something wrong with the group, and others have reported it too. Unfortunately my google groups account is plagued by “The owner of this group has banned you from this group.” in all groups, even those I’ve never visited before. I’ve tried emailing google groups support, but haven’t heard anything. So this makes it impossible for me even begin to investigate a solution. Its been a few weeks now for both issues so we may just need to move all tickets + discussion elsewhere.

    ~/Library/Application Support/ and /Users/username/Library/Application Support/ should be the same folder. But, yes add the Bundles folder if it doesn’t already exist. Typically this folder is created when you first extend any bundle or create a new bundle yourself via TextMate.

  39. Matthias says:

    @Deke
    If you have cloned the Bundle from the git repo,
    open a terminal and run the following commands:

    cd ~/Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle
    git reset --hard a89dcbfd6bb37f827df

    This will undo some recent changes.
    It is not an elegant solution but the
    commands in the Rails bundle will work again.

  40. Matthias says:

    The engine has eaten a dash!

    There must be TWO DASHES before the hard in the second command.

  41. Dr Nic says:

    @Matthias – I’m confused which commit you are rolling back to. On http://github.com/drnic/ruby-on-rails-tmbundle/commits/master which commit is this? That is, which subsequent commit is causing the problem?

  42. Dr Nic says:

    @Mattias – fixed.

  43. Jonathan says:

    Hi – the generator scripts aren’t working. They’re pulling up the window saying successfully generated model, but with no output and no result. Any tips on how to debug the problem if not solve it?

  44. Mikael says:

    Sorry if this is not related in any way but I’ve replaced my original bundle with this one (following the guide) but is there a difference between bundles and themes? Because I thought I would have my “belongs_to” in red (like my friend has in his TM theme, and we’re using the same versions and theme)..

    Maybe I’m thinking of this the wrong way but isn’t this one suppose to do that for me?

    Thanks