Replace hard-coded ":id" with data from model

@kakra I've added tests to your commit. The Rails 4 update is coming, and I don't want any surprises!

Merging this and closing #39. Thanks.