Ruby on Rails problems & solutions - Dec 2, 2010

December 3, 2010

Today seemed to be all about re-discovering stuff that I had done before… but so looooong ago….

So, how do I… update a single attribute, on multiple ActiveRecords?

I have a list of jobs. Jobs (multiple) can be selected. And then, you can “move” (change state) on these jobs. So, I wanted a controller action to update a single attribute, on multiple jobs. This seems to do the trick. And how do I do Basic HTTP authentication again? I have used Basic HTTP authentication before, but it was so long ago, that I had completely forgotten how to do it. Nice, simple example:… And how about testing (spec’ing) that? Of course, if you are going to add Basic HTTP Authentication, it has to be tested, right? I’ve tested it before, but never with RSpec. Interesting that the first several Google’d links produced bad answers. But I persevered, and found one that worked:… <— correct

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