@mrob: This is probably (definitely) obvious, but when I get errors like that I start by logging out the raw post data and making sure everything is coming through like I expect it to. I'm assuming Rails has the equivalent to Laravel's dd().
Once I had that string I'd try running it through the parsing function in isolation. Take variables out, get it working on one example, then work back from there.