I have a model, Project, which has two belongs\_to associations to the same model:

```
belongs_to :source_connection, class: Connection
belongs_to :destination_connection, class: Connection

```

But on the other side, each connection should have only one association to the project. Adding

```
has_one :project, foreign_key_id: source_connection_id
or
has_one :project, foreign_key_id: destination_connection_id

```

Isn't going to cut it, because the connection itself has no knowledge of whether it's a source or destination connection.

Clearly there's a flaw in how I've designed this association, I'm just curious as to what the right way to go about it is. It's worth mentioning that 'Connection' has a lot of inheriting classes (SSHConnection, S3Connection, etc), so splitting the Connection class into 'Source' and 'Destination' Connection models would cause a lot of duplication.

Any thoughts welcome.