Ruby on Rails problems & solutions - Feb 4, 2011

February 4, 2011

RSpec and weird error on stub and raise InvalidRecord

I was baffled by this error, when I was trying to test my “rescue_from” code, on some validation errors.  I kept getting:

wrong number of arguments (0 for 1)

Here’s the guy who asked the right question:


And here’s the answer.  Seems obvious in retrospect, sigh.


Roles and Authorization, With authlogic

Was doing a lot of work with roles in the Rails 3 project, where we already used authlogic.

This is a nice little add-on, with really basic stuff:

However if you need industrial-strength roles, and we did, then you’ll probably want to go with acl9

Note that acl9 is not for the faint of heart.  The examples were … not really relevant to what I needed to do, so I kind of had to figure it out on my own.

Foreign key gem

I stumbled across this gem, in the search for something completely different:

It certainly looks good, but I haven’t had a chance to try it out, yet. If you have, please comment!

} 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(); });