Ruby on Rails problems & solutions - Apr 8, 2011

April 8, 2011

RSpec view debugging hackI needed to see what the rendered view looked like, so I could figure out why it was finding “1151” instead of “1” in a tr>td selector.  I knew how to do this in RSpec 1, but not in RSpec 2.

Not a web reference solution to this one, I found it in the RSpec book.  If you are using RSpec, I can’t imagine why you wouldn’t want to buy this book.

The answer is “rendered”.  As in:


puts rendered.inspect

Not pretty, but it works.  Yes, I know… debugging by println (I’m aging myself with that, aren’t I?).  Sometimes the “not pretty” way is the quickest, though.

RSpec’ing with acl9

I was using acl9 ( in my Rails 3 project.  Now, I have specs for the acl9 functionality, but I started bumping into it on all my controller specs, and I wanted to skip it.  Again, I have this working in my old Rails 2.x app, and RSpec 1.x, this is the new and improved way, with some specific gotchas for acl9:

Password change dialog

Finally got around to implementing that password change story (That’s right, suckers, you CAN launch without something that seems really basic).  Sometimes, you find really old stuff:

Take the old stuff with a grain of salt, because it may be total junk.  OTOH, it may still be the definitive answer.  But I kept looking, and found this:

which I liked a lot better, from a purist, RESTful point of view.  However, since I am using authlogic, it couldn’t be that simple, could it?  So…

Rechecking password with Authlogic

Relevant code bit:

@current_user.valid_password? params[:old_password]

Like what you’ve been reading?  Live in Western Canada (or there abouts)?  Sign up at, to stay informed about the next upcoming Ruby on Rails for Rail training class, held in Calgary, AB.

} else { $('#cookie-notice').show(); } $('#cookie-notice-accept').click(function() { createCookie('cookie-notice-dismissed','true',365); // Change from 1 month to 1 year. $('#cookie-notice').hide(); });