mongoid/mongoid — pull request #3253 by arthurnn (2013-09-06 04:24:19+00:00)
Title: has_many must use the inverse fk when query

`determine_foreign_key` was not following the inverse name to get the fk when the fk was not stored in the doc. Instead we were using the class name to determine the fk, which is not always true, if the other side defines a different name for the relation.

* Also the fk should return nil if is a embedded relation. As embedded relations dont have fk.
* Also we should not rely on the method `String.foreign_key` from active_support, I might even send a patch to them to remove that method, because it doesnt make sense to have it on the String class.

@durran for a quickly review.

[fixes #3242]