kidpollo/tanker — pull request #78 by dontfidget (2014-05-25 01:23:50+00:00)
Title: use rails4 find_by method when available

In rails4, it looks like tanker will use `find_all_by_id` if activerecord-deprecated_finders is in your Gemfile but otherwise it will fall back to `find`. `find` behaves differently than `find_all_by_id` because it will raise an exception unless all models are present. To allow the current behavior to continue in a rails4, without requiring `activerecord-deprecated_finders` as a dependency, we can use the rails4 find_by(id: ) method if it is available. I imagine we could also use `where` but this seemed to be more in the spirit of the existing code and I'm not sure myself if `where` has different behavior. The use of a dynamic finder was added with commit 02b623a2 and it's not clear to me why in the commit message why this was done (maybe it was just done so it could be stubbed for testing). I would argue that falling back to `where` prior to rails3 (or for some other ORM) isn't the right behavior either, but I'll leave that for others to deal with. I have added a test that describes the behavior when none of the dynamic finder methods are available.

Thanks for your consideration,

Andrew