Dynamic Finders Return nil

The first thing you should do is to make sure this is a Rails bug. For example, you should create a fresh application with no other gem and see if the problem arises.

In that case, you could push the application source to GitHub so that others could try to replicate the behavior.

If you can't replicate this behavior in a fresh application then there is probably some gem changing the behavior of ActiveRecord. In that case you could try publishing your Gemfile.lock to a GitHub gist or a similar service and posting the link (probably on rails-talk) so that others could try to help you to identify which gem is introducing this bug.

Finally, debugging in Ruby is pretty easy. Just put a breakpoint (debugger method) before the find_by_id statement and step into it. You'll be able to investigate the stacktrace on each step to see why it is returning nil. This will certainly help you to investigate what is causing the issue.

If you find a bug in ActiveRecord, submitting a pull request with a test case for it would get your bug fixed soon.

Hope that helps,