has_one through not available on unpersisted instances
Opening a new issue since the old one was marked as stale and I didn't get to it in time (doesn't seem like I can re-open it).
https://github.com/rails/rails/issues/31975
@adamlogic confirmed that this still reproduces on current master: https://github.com/rails/rails/issues/31975#issuecomment-397656705
Note: I believe the way that this works is by associating with post_id, so if that's the case it makes sense that this would be the behavior, and I suppose this becomes an enhancement request.
Comment knows that it has a Post associated with it as evidenced by the passed assertion on L66, so is it possible to leverage that relationship to make the through association work?
Steps to reproduce
Script to reproduce: https://gist.github.com/zachwalton/395412f5b7e97837e6273981dbb7faf3
Expected behavior
owner should be not be nil when accessed through the has_one through association
Actual behavior
owner is nil when accessed through the has_one through association
System configuration
Rails version: 5.1.2
Ruby version: 2.4.2
Source: rails/rails