Jason Michael dot com

My personal blog

Conflicting Scopes and How to Make Them Play Nice

| Comments

If you do enough with Rails 2, you’ll be using named scopes (I think they’re frowned upon in Rails 3). I use named scopes for everything, particularly when I need to write complex queries which involve joins of tables. In this example, I have these models: an Rca, a Root Cause Analysis document, which is a report on a system failure and why it happened, a GenericProfile, which is a generalization of a System which might have a failure, an ImplementationType, which is a way a System might be implemented, a SoftwareRelease, which is the software the GenericProfile (System) might be running, and a FeatureGroup, which is a collection of SoftwareReleases. When talking about Rcas, we need to group them by ImplementationType and by FeatureGroup, so we can say “show me all the Rcas that refer to this System type”, or “show me all the Rcas that refer to this method of implementation”. We can do this with named scopes.

Making Pdfs

| Comments

I have been converting all my ‘show’ and ‘index’ actions in my rails app to pdf’s using prawn. It works great. here’s the manual: link

Generic Multiple Attachments in Rails

| Comments

If you use paperclip for attaching pictures to models in Rails, you’ve probably run into this problem. At first, you’ve added a picture called ‘diagram’ to an MVC called WhitePaper, and it works fine. You can click on a link (diagram_url) and it pops the picture up in your browser, and everybody says “Wow!” Then people start asking you to attach other pictures to other models, and more pictures to the WhitePaper model, and you discover that you’ve become an idiot. Every time somebody asks for an attachment, you have to add code. And you thought Rails was agile!

Erlang on AWS

| Comments

AWS and Amazon Elastic Cloud could be the best playground for erlang projects. I’m going to experiment with using EC2 to build a variety of erlang “Hello World” projects.

Home Robotics

| Comments

Spend an hour or so on the internet, and it’s immediately clear to anyone with half a brain that one can purchase and assemble without too much trouble a truly powerful home computer, complete with optical drives, processors, memory and a fixed disc. This computer can be both as powerful as and sometimes much more powerful than commercially-available products from Dell, HP etc. So, why can’t the same be said for Robotics?

Attack

| Comments

The creature, if you could call it that, was very nearly transparent. It floated through the sky like a giant condom filled with a now cloudy and then clear, undulating fluid. There were no structures visible within it’s external membrane, nothing that a modern biologist would recognize anyway. Inside, it was a total mystery, but outside, across it’s skin, it was covered with a slick, shimmering layer of hydrofloric acid at such an amped up concentration so that it would eat through living flesh almost instantly.