Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Standup 9/14/2009: State Machines, comments in ERB, test-unit 2.0.3 breaks RSpec

Ask For Help

“Anybody use an off-the-shelf State Machine plugin for Rails? Which one?”

Our team recommends using the rubyist-aasm gem from Github. It works well for our current applications, and it appears to be the most actively developed and frequently updated. This gem is the successor to the acts_as_state_machine plugin.

Interesting Things

Don’t use comments in ERB. Writing comments (or any ‘#’ character, for that matter) inside an ERB evaluation block was never right, but some versions of Ruby 1.8.6 allowed it anyway. This is trouble if you upgrade to Ruby 1.8.7 (for example, when upgrading to Snow Leopard) which does not allow comments within ERB.

This is wrong:

<%= link_to "/", home_path #link to the homepage %>

If you really need comments in ERB, do it this way:

<%# link to the homepage %>
<%= link_to "/", home_path %>

test-unit 2.0.3 breaks RSpec. If you upgrade to test-unit 2.0.3, you may notice that your RSpec specs no longer run. Roll back to test-unit < 2.0 (or remove the test-unit gem completely) and you should be back in business.

RubyMine 1.5 early release is available for trying out. Preliminary reports from one Pivot are positive. If you are using Snow Leopard, which ships with Java 1.6, you’ll need to do this hack to get it to run

  1. Marko says:

    Exactly, I’ve also noticed that sometimes putting a comment inside a non-outputting ERB tag might result in bad rendering (something missing from the part that follows it).

  2. I’ve been loving pluginaweek’s state_machine on a few projects. Nice and simple, and not tied exclusively to Rails.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *