Sunday, February 18, 2007

AWebFactory - a helping hand for RadRails

jEdit + RubyPlugin is a great, simple Rails development tool, but I was getting annoyed today by the need to open two console windows (one to run Mongrel, another to do rails config or rake work), a Web browser and jEdit, then cd to the depot application folder and manually fire up the Mongrel server every time I wanted to do a little more work on the AWDWR depot tutorial.

I thought about writing up a Windows batch file to start up all this stuff for me, then I realized that I would be cobbling together more or less the environment RadRails provides out of the box.

Since I was well into the depot demo application I wanted to import it to RadRails. A quick Google search let me to Victor Kane's AWebFactory - an amazing resource if you want to use RadRails while following along in AWDWR. Even more so, Victor illuminates many of the darker corners of MVC, OO and Rails that beginners might struggle with. Thanks for taking the time to write this invaluable guide, Victor!

Update (14 May 2007): Aptana has taken over development of Radrails, slowly integrating it into their Eclipse-based Web development IDE. The Aptana team and community are breathing new life into Radrails.

Thursday, February 15, 2007

Found a sweet spot!

Wolfman has posted some great stuff at the intersection of jEdit, Rails and HAML, especially the set of Superabbrev shortcuts for Rails development!

Sunday, February 11, 2007

Ruby on Rails for enterprise gaining ground?


I work for a big systems engineering firm (big by Canadian standards) with over 30 years of system and software engineering success. Much of that success is attributed to the company's conservative, risk-averse engineering culture. Nonetheless, a few brave souls within the company are embracing and succeeding with Agile ways. Ruby on Rails promises to ratchet Agile productivity up a notch or two, even for conservative, risk-averse enterprise projects.

In December 2005, Quoted-Printable published a link to a thought-provoking article by Obie Fernandez on the business value of Ruby on Rails. Fernandez predicted a big gain for RoR in 2006, thanks to the "productivity arbitrage" gains of RoR . So, did RoR gain ground in 2006? Was Fernandez on the money? Here's my totally unscientific search for the truth:

David Heinemeier Hansson first released Rails to the world in July 2004. According to a graph produced on Google Trends, the phrase "Ruby on Rails" makes its first appearance in Google searches in early 2005, climbs steadily through the rest of the year, then declines in 2006. Google provides no scale for the number of hits in the vertical scale (there must be a more scientific term for this), so all of the comparisons that follow are relative.

Over the same period, the terms "Java" and "J2EE" declined slightly on Google. A search for "Spring framework", representing the latest trend toward lightweight Java, shows a gain through 2005 followed by a marked decline in 2006.

So does this mean RoR is not gaining ground, or that web users are not searching for these terms as much as they first did, sort of a "framework fatigue" setting in?

Currently in a search for the term "Rails" on Google, eight of the first ten results are directly related to Ruby on Rails. The first five results point to Ruby on Rails-related sites, followed by Rails of Sheffield's "New and used model railways." The result may reveal more about Google's indexing algorithms than shifting patterns in the search term, but it provides some insight.

In the mean time, the first Railsconf in mid-June 2006, sponsored by non-profit advocacy group Ruby Central, sold out to an audience of 600. This year Ruby Central partnered with tech publishing behemoth O'Reilly to double the number of seats at Railsconf 2007 in Portland, Oregon.

Prompted by a fevered posting to the Rubyonrails weblog, last Monday, I succumbed to the hype and registered, even before I had the go-ahead from my employer's professional development program coordinator (yes, they have a great training and pro-D program!).

As of this posting, the conference is already three-quarters sold out, one week after registration opened!

Glad I bought my ticket early.

Sunday, February 4, 2007

require_gem is obsolete?

A discussion about the warning "c:0:Warning: require_gem is obsolete. Use gem instead". I couldn't get this one to work on my home box (Rails 1.2.1, Ruby 1.8.5 on Windows XP SP2) so I'm just ignoring it for now, hoping it's not critical. I'm still so new to RoR that I don't know what's important yet. I'm hoping the Ruby and RoR maintainers will fix this one soon?

Update (11 Feb 07): Rails 1.2.2, released on 6 Feb, fixes the problem, along with support for SQLite3 - you'll need gems 0.9.0 or better now.

Saturday, February 3, 2007

jEdit for Ruby on Rails

I received my copy of Agile Web Development with Rails yesterday, and eager to get started, I fired up my long-time favourite code editor, jEdit. Over the past five or six years I've used jEdit for just about every coding task I've ever undertaken, so I decided to try it out for Rails work.

After a couple of hours of downloading plugins and fiddling around with settings, I decided to save my notes here in the hopes that it would save you some time (and so I'd have it written down somewhere for the next time!). I'll assume you're starting from scratch:

  1. Download and install Exuberant Ctags (supports the CTagsSidekick plugin). According to the plugin docs, you need a recent version of this program.

  2. Check the system requirements for jEdit, then download and install the appropriate Java Runtime Environment.

  3. Download and install jEdit.

  4. If all is good, fire up jEdit, then select the menu Plugins -> Plugin Manager.

  5. Select the Install tab, then select and install the following plugins:

    • CodeBrowser: provides a tree view of the document structure

    • Console: integrated command-line with some smarts.

      • Doesn't work so well with applications that don't immediately flush their output buffer, e.g. for tailing WEBrick output.

      • Works well with the ErrorList plugin to highlight runtime errors in Ruby code.



    • CTagsSidekick: another, somewhat slicker document structure browser.

    • ErrorList: as the name implies, displays a list of errors generated by SideKick parsers

    • ProjectViewer: Best of the half-dozen project organization plugins. Some integration with console, e.g. switching the project view as you navigate the source tree in Console, or switch buffers in the main text edit view.

    • RubyPlugin: the big kahuna - makes jEdit a into real Rails locomotive :) I can't say enough about the features it provides, just read up on the author's site.

    • Sidekick: provides the framework for CTagsSidekick to do its magic.



    • XML: provides an HTML parser and tag completion facility for Sidekick



  6. Most of these plugins should install without a hitch. You might have to restart jEdit to let it find and install all of them correctly.

  7. Once all of the plugins are happily installed, select the "Plugin Options..." from the "Plugins" menu, then update the following plugin settings:

    1. Code Browser:

      1. Enter the path to the Ctags executable (e.g. on my system it's C:\Ctags\ctags.exe).



    2. Ctags Sidekick:

      1. Enter the path to the Ctags executable (e.g. on my system it's C:\Ctags\ctags.exe).

      2. Set "Group tags by" to "namespace (multi-level)"

      3. Click "Show icons" if it isn't selected.



    3. SideKick:

      1. In the Parsers section, set "rhtml" mode to the "html" parser, and "ruby" mode to the "ruby" parser.



    4. ProjectViewer:

      1. If you plan to use ProjectViewer to manage your Rails projects, add *.rb, *.rhtml and *.yml to the "Files to import" field of the "General Options" section.



    5. Click "OK" to save the settings and close the Plugin Options window.



  8. Select "Global Options" from the Utilities menu, then update the following settings:

    1. Editing:

      1. Select "html" from the list of modes.

      2. Uncheck "Use default settings".

      3. Add "rhtml" to the "File name glob" field, like so: *.{html,htm,hta,rhtml}



    2. Shortcuts:

      1. Select "Plugin: RubyPlugin" from the "Edit Shortcuts" list, then add the shortcuts as suggested on the jEditPlugin Features Page.



    3. Click "OK" to save the settings and close the "Global Options" window.



  9. Also see the excellent tips on Eadz's Ruby on Rails on jEdit page, and this howto on setting up RoR abbreviations.

  10. Best to restart jEdit so the buffer mode changes take effect.

    • You can confirm the mode is HTML by opening a .rhtml file then checking that HTML mode is displayed in the status bar, e.g. "(html,indent,Cp1252)".

    • Also, select the "Beautify Buffer" command from the menu Plugins -> Beauty. It should tidy up the HTML formatting.

    • Finally, a list of HTML tags should pop up when you type an opening tag bracket "<".

    • Sometimes jEdit "forgets" the mode it's using. Just restart it - it will remember where you were editing the file and which files you had open. Sweet.




That's about it. I welcome any and all corrections or additional tips!