Rails (and family) on Lighthouse

Lighthouse “version 2” deployed yesterday, so I’m officially opening the Rails Lighthouse tracker up for business. Other spinoff projects such as Prototype and Capistrano have already made the switch. As David has mentioned, this means the current trac instance is deprecated. It will continue to stay in use for now until everyone has transitioned to Lighthouse.

We’re still figuring out the new workflow with git, Github, and Lighthouse. I’ll be working with the Logical Awesome folks to improve the Lighthouse/Github relationship. I’m also working with Tim Pope (author of the awesome git-trac tool) and others in #rails-contrib on bringing the same development tools to the new git infrastructure. Tim also wrote some best practices for contributing to Rails from git.

Posted in Launches, Tools  | 18 comments

IntelliJ IDEA 7 with Ruby on Rails support

IntelliJ IDEA has long been regarded as one of the best IDEs for Java development. With the 7.0 release they’ve followed Netbeans and Eclipse by offering significant support for Ruby on Rails alongside the Java tooling. They have a neat video tutorial showing off the Rails features.

Posted in Tools  | 12 comments

Rails tool space is heating up

There’s a lot of action going on in the Rails IDE space these days. Besides Aptana RadRails, which has been around for a long time, Sun’s got impressive Rails support in the new NetBeans, and just this week CodeGear launched their 3rdRail IDE, which also looks like a great setup.

I’m personally not quite ready to leave TextMate behind, but it’s encouraging to see all these options for dedicated Rails IDEs. It’s not going to be long before they’ll be giving regular text editors a serious run for their money.

Posted in Tools  | 24 comments

Rails 1.2 Performance

Stephan Kaes, our resident performance expert, has released a new version of RailsBench. He then created new Rails 1.2 vs Rails 1.1 benchmarks, discovering that things aren’t as bad as they seem. Of course, those numbers won’t mean a whole lot until you read the full report

Posted in Sightings, Tools  | 13 comments

IntelliJ jumps on Ruby and Rails

JetBrains’ IntelliJ has long been the gold standard for Java IDEs. Now the company is taking a shot at turning their suite into a good fit for Ruby and Rails development. This new love is coming in the form of a new official Ruby plug-in.

It features assisted Ruby coding, with keyword completion, syntax highlighting, on-the-fly code validation, error highlighting, and Rails templates and generator integration. They even put together a screencast to show it off.

Cool stuff. Especially if you already plugged down $400 for a license or work on an open-source project (free license, then).

Posted in Tools  | 24 comments

In case you're having trouble installing gems...

A significant number of Rails developers have reported problems installing gems with the updated RubyGems release. If you’re experiencing a problem that looks anything like this:

$ gem update sqlite3-ruby Updating installed gems… ERROR: While executing gem … (NoMethodError) undefined   
  method `refresh’ for #

...you should remove your local source_cache file. This is the file that locally caches any gem metadata from the gem server to avoid having to re-download it every time you execute a gem command.

To discover the location of this file on your system, run the following command:

$ gem env
RubyGems Environment:
  - VERSION: 0.9.2 (0.9.2)
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
  - GEM PATH:
     - /usr/local/lib/ruby/gems/1.8
  - REMOTE SOURCES:
     - http://gems.rubyforge.org

The source_cache file should be in the path labeled by GEM PATH. Removing that file should clear up any related issues.

This solution is a workaround pending a fix by the RubyGems team.

Posted in Tools  | 16 comments

RailsBench available as gem

Stefan Kaes’ RailsBench benchmarking suite is now available as a gem. This makes it even easier to get started benchmarking your application and find bottlenecks. Yay for ease of installation.

Posted in Tools  | 6 comments

Unobtrusive Javascript Plugin

Dan Webb and Luke Redpath have release the latest version of their Unobtrusive Javascript Plugin for Rails. It solves several of the main problems people run into when working with unobtrusive javascript:

  • Development isn’t as intuitive with Rails when you’re defining your custom javascript behaviors in an external file.
  • When working with pages with lots of images and content, the behaviors won’t be enabled until everything is downloaded and window.onload is called. It’s been solved with some nasty cross-browser javascript hacks, all handled transparently by Dan’s LowPro extension for prototype. This has been a big deal for me personally, so it’s nice to see it all solved.

UJS attempts to solve this by taking defined behaviors in the view and creating a tailored javascript file for it. Smart conditional GET and page caching techniques can be used to save bandwidth and time.

All in all, it looks like Dan and Luke did an excellent job on the plugin. Anyone using it? How’s it working out for everyone?

Posted in Sightings, Tools, Tricks  | 10 comments

Remember CRC Cards?

Last week I was chatting on IRC with some cool and clever Rails developers, and made a comment about not being able to proceed with a design because I couldn't find my 3x5 cards. No one seemed to know what I was talking about. Why would I need 3x5 cards to design software?

It seems that many Ruby on Rails developers are just starting out with object-oriented programming. And many of them are finding it can take a while to reset their brains and escape the procedural way of thinking. Some try to use tools like UML, but while UML can be good for documenting a design, I've never found it helpful in actually creating the design. What does work is CRC cards. CRC stands for Class, Responsibility, and Collaboration - the fundamental elements of object-oriented design.

Read more...

Posted in General, Tools  | 10 comments

Dan Webb's Request Routing Plugin

Have you ever wanted to write Rails routes using a URL's subdomain? What about routing based on whether a request was HTTP vs HTTPS? Well, now you can. Recently Dan Webb released his "Request Routing Plugin":http://svn.vivabit.net/external/rubylibs/requestrouting/README for public use. This plugin lets you create routing rules that use a whole slew of new properties: domain, subdomain, method, port, remoteip, contenttype, accepts, requesturi, and protocol.

You can obtain the plugin from Dan's subversion repository:

ruby script/plugin install \
   http://svn.vivabit.net/external/rubylibs/request_routing/

Posted in Releases, Tools  | 8 comments

New in Rails: Module#alias_method_chain

Though not an outward facing feature, changeset 4276 introduces a nice method to DRY up and encapsulate the common pattern of aliasing a method so that you can build behavior on top of it.

All over the internals of Rails you’ll find code like this in a module:

  module Layout #:nodoc:
    def self.included(base)
      base.extend(ClassMethods)
      base.class_eval do
        alias_method :render_with_no_layout, :render
        alias_method :render, :render_with_a_layout
        # ... etc
This makes it so that when the module is included into the base class, it adds behavior onto some method in that class without the method having to be aware of the fact that it’s being enhanced. In this case, the render method of ActionController::Base is enhanced to wrap its output in a layout. The new Module#alias_method_chain wraps up this pattern into a single method call. The above example, once refactored to use Module#alias_method_chain, would simply be:

alias_method_chain :render, :layout
This will be used to refactor quite a bit of Rails internals which may not be of immediate relevance to what you do, but it serves as a nice example of the mechanisms Ruby provides for software organization. Small victories.

Posted in Tools, Tricks  | 5 comments

Stress testing your protected pages

David came up with a quick tip for anyone stress testing protected pages with a stateless tester, such as siege.

  1. Log in with your browser
  2. View the cookies and find the session id (Firefox has a handy cookie search tool)
  3. Prepend the queries with ?_session_id=YOURSESSIONID

Now, any requests made will be as though they came from your account.

Do you have any other handy tips for stress testing your Rails applications?

Posted in Tools, Tricks  | 11 comments

Plug into HyperEstraier with acts_as_searchable

Patrick Lenz has announced his acts_as_searchable plugin which integrates ActiveRecord models with HyperEstraier, an open source fulltext search engine.

It’s available as a gem so you can just do sudo gem install acts_as_searchable.

You can then take a look at the API docs, which provide a few examples.

Full text searching just got as simple as:
class Article < ActiveRecord::Base
  acts_as_searchable
end

Article.fulltext_search('biscuits AND gravy')

Posted in Releases, Tools  | 16 comments

Quick PDF generation with RTex

Bruce Williams of Naviance recently announced his RTex plugin. It exposes your controller data to rtex views that output LaTeX which is convereted to PDF.

To install you can use the plugin script:

ruby script/plugin install rtex

Or grab it from svn:

svn co http://codefluency.com/svn/codefluency/rails/plugins/rtex

People have used PDF::Writer to generated .rpdf views. Why go through LaTex to get to PDF rather than use PDF::Writer? Speed, says Bruce.

Posted in Releases, Sightings, Tools  | 9 comments

Auto sanitized templates with Erubis

Last month on the Rails core mailing list, a thread popped up (that went on and on) wherein the idea was proposed that rhtml templates should automatically sanitize output by default. After much back and forth, David suggested those in favor redirect their energies toward a working plugin.

Enter stage left, Erubis. It’s a customized implementation of eRuby that provides a handful of features, notably that <%= %> tags automatically sanitize output. You use <%== %> if you don’t want to sanitize the output. For all those who wish rhtml files were sanitized by default, here is your solution.

Configure your Rails apps to use Erubis templates with ActionView::Base::register_template_handler.

Posted in Releases, Tools  | 11 comments