Validating a polymorphic association for a new record

Posted on September 30, 2011

Currently, in Rails, if you have a validates_associated on a model with accepts_nested_attributes_for, it will fail when creating a new record. (It fails because the foreign key is nil ... because the object doesn't exist yet.) Normally, using inverse_of solves this problem. However, with polymorphic associations, this doesn't work. What would the point of defining the inverse_of a polymorphic object when polymorphism allows the associated ...

Read More


Restoring my dev machine from a Time Machine backup

In what turned out to be the second worst news of the day, I found out my computer was stolen from our office. (The worst news came in the form of a realization that I was not going to get a cab and instead had to subway it home with a 10 pound box of frozen meat, a new laptop, my big-ass purse, and a bag containing 3 pound ankle weights, 2 pound wrist weights, and foam roller. It was awesome.) Fortunately, I'm anal (and lucky that my Time ...

Read More


Debugging Cucumber in RubyMine {Quick Hit}

Using Cucumber and Rspec for the first time has been ... a little frustrating. I followed along with the main tutorial in The Rspec Book and then skimmed the later chapters. I thought it was quite good until I had to start testing an actual rails app and felt a little at a loss. But I digress ... (more…)

Read More


Quick Hit: Library not loaded: libmysqlclient.16.dylib

I haven't been using mysql much for my rails projects in favor of postgres, but in doing some tutorials on haml and sass I needed mysql in order to follow the tutorials exactly. After adding the mysql2 gem to my Gemfile, I got this error when running rake db:create: (more…)

Read More


Quick multi-site javascript RSS feed

I just finished quickly putting up a simple, compilation site. This was a business was a group of successful blogs, who had recently moved all their emails addresses to be under one header. As a consequence, people were occasionally hitting the email url. At the time the url just redirected to the flagship site, but the owner wanted the site to be a bit more informative without too much effort. All that was needed was an intro and an RSS ...

Read More