Rails 3.1.0.beta1

The hubby (a longtime PHP developer and fellow Rails n00b) is super-excited about the recent release of the Rails 3.1 beta because it has support built in for things like Sass (a.k.a. SCSS) and CoffeeScript. These things are nifty, although besides Sass, I’m only vaguely aware of most of the things he lists off. I agree, the new version of Rails will be fun. Where we differ is how much fun trying to use it in beta is.

I’m used to how things work in Rails 3.0. I didn’t have any real issues with how it worked, because I don’t do enough scripting (read: almost none) to care about CoffeeScript, and I was content getting the hang of regular CSS before branching out into Sass. My projects weren’t of a scope where I needed those features. So switching to 3.1 for a project the hubby wants to work on with me was more a favor for him, and I thought it would be an opportunity to get used to some of the features a little earlier.

Hoo boy.

I forgot, or perhaps didn’t really know, how difficult bugs can be to track down in a beta, especially when I make plenty of new and exciting mistakes on my own at this point that I have to diagnose. And there are some fun ones to make when moving a project from one version to another!

Project Migration
For example, after I renamed my old version of the project, I had to copy over “just the essential files” to the new version of the project. First try, I copied over way too many things and broke it. Rather than try to roll back the changes I’d made, I just started over. Second try, I copied over only the page code and the routes file. When I tried running my site locally (just on my own browser, not on the web), I found I needed to copy over my javascripts, stylesheets, and images. So I added all those things into the ‘public’ folder where they lived in 3.0, but it turns out they live in a new place in 3.1, the ‘app/assets’ folder. And then I had to change the lines of Ruby in my application layout that called the stylesheets and the javascripts that I use because the syntax changed! And finally, I needed to copy over my ‘db/migrate’ folder and run “rake db:migrate” to make my user model work again.

Password Migration
Then the hubby found out that in 3.1, password encryption is a built-in feature (which is an AWESOME change), so I rolled back two migrations in which I had implemented my own password encryption. Then I spent a while looking at the one blog post everyone linked to on the topic and trying to figure out what the heck they meant by “Your model will need a field called password_digest”. Where was I supposed to add that, and how? Well, it turns out that means you need to add a column to your database table with a migration:
class AddPasswordDigest < ActiveRecord::Migration
def up
add_column :users, :password_digest, :string

def down
remove_column :users, :password_digest

And then run “rake db:migrate”.

Annotate: Broken?
So I did that, and then I wanted to annotate my models to see if the changes had gone as I expected, at which point I ran into a whole new problem: I couldn’t run the command “annotate”. So I tried to add it to my Gemfile. It was already there, it seemed, but I tried moving it into a different group. I tried different annotation gems. I tried destroying my Gemfile.lock and re-running “bundle install”. Nothing worked. I thought the beta had broken something badly. I finally gave up on Google to answer the question and was writing up a question on stackoverflow.com when the hubby looked over at my screen and asked what was going on. With his greater experience in debugging, he found out that the problem was that I hadn’t quit my text editor between when I deleted my first attempt at the project and when I created a new attempt of the same name. Basically, the version of the Gemfile I’d been editing was the version in the trash. D’oh! But come on, how un-intuitive is that?

And now, annotate is STILL broken! It shows up as being installed now, but it still gives errors when I try to run it. It hasn’t been updated since November 2009, so it may just be broken with the new version of Rails. Ick.

Also busted in the beta: autotest. This makes me very, very sad. Having constant reporting on whether my tests pass is really nice, and would have been extra-nice now, when a bunch of stuff is broken and I’m going to have to rewrite at least half of my tests. At least running “rspec spec” still runs my tests, but doing it manually after each of my adjustments is going to be a pain in the butt. Update: Autotest actually works fine, I just broke it in my upgrade process. Details in my next post.


About joanwolk

3 things I like: theater, food, geekery. 3 things I don't like: clichés, blisters, coffee.
This entry was posted in Uncategorized. Bookmark the permalink.

6 Responses to Rails 3.1.0.beta1

  1. Daniela says:

    You can just run “rake” instead of “rspec spec”, does the same thing!

    • joanwolk says:

      Hm. That does work, but it throws an error (“rake aborted!”) at the end, and it runs slower than “rspec spec”. I know “rspec spec” is running faster than baseline because I run spork in another process. I do have to restart spork after particularly major code changes, but it’s a huge speed boost overall.

      Ultimately, my real complaint is that I have to run anything manually; whether it’s “rake” or “rspec spec” is pretty unimportant.

      • kstuart says:

        strange, have no issues with autotest/spork.

        also ‘rake spec’ should not abort, run it with ‘–trace’ to find the problem, that may also be what’s causing autotest to fail.

      • joanwolk says:

        @kstuart: Thanks for the tip! I get about 25 errors when I run the trace. Most of them are in [myfilesystem]/.rvm/gems/ruby-1.9.2-head/gems/rake-0.8.7/lib/rake.rb, with another three in [myfilesystem]/.rvm/gems/ruby-1.9.2-head/gems/rspec-core-2.5.1/lib/rspec/core/rake_task.rb and a couple of other files with single errors. I’ll have to look into that.

      • joanwolk says:

        @kstuart: I got all my tests passing, at which point “rake spec” no longer gives an abort message at the end of the testing.

        Autotest is still not running, but I’ve realized I’m getting some kind of conflict between rspec and cucumber when I start spork. The problem is likely in to be found there.

  2. Pingback: Fixing my autotest after switching to Rails 3.1.0 | git init and get in it!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s