There is some confusion for me.
Award
belongs_to :poem
has_one :overall_ranking, :foreign_key => :poem_id
Here you are using the same id for both relation. This means that you try to retrieve the overall ranking with the poem id.
If I translate to sql you say something like:
overall_ranking.id = poem_id
I think this is wrong.
If you like to have the same overall_ranking
for award
and poem
you can write something like this:
Award.rb
belongs_to :poem
has_one :overall_ranking, :through=>:poem
You can include like
Award.all(:include => [:overall_ranking])
or nested
Award.all(:include => [{:poem=>:overall_ranking}])
Update
1.Your has one association is set up incorrectly.
Please see: http://blog.hasmanythrough.com/2007/1/15/basic-rails-association-cardinality
Award
belongs_to :poem
belongs_to :overall_ranking, :foreign_key => :poem_id
OverallRanking
belongs_to :poem
has_one :award
You always should have belongs_to at the model where you store the referencing id.
2. But this not resolves your problem in your logic.
With this you will still has association between Award#poem_id = OverallRanking#id
. You should have Award#poem_id = OverallRanking#poem_id
.
I suggest to add overall_ranking_id
to Award
and things become much cleaner.