Take the following associations based on a Feedback model:

feedback.rb

```
belongs_to :buyer, :foreign_key => :buyer_id, :class_name => "User"
belongs_to :seller, :foreign_key => :seller_id, :class_name => "User"
belongs_to :listing

```

The reverse associations are `has_many`

When `creating` the feedback object it could be 'anchored' to any of the above other objects (e.g. `buyer.feedbacks`, `seller.feedbacks`, `listing.feedbacks`)

---

Say in this example we want to primarily link it with the buyer and so `nest the feedback routes within user` and then build a create action in the Feedbacks controller that looks something like:

```
current_user.feedbacks.new(feedback_params)

```

### or is it more appropriate/correct to reference?

```
buyer.feedbacks.new(feedback_params)  

```

### Is this even valid without an explicit buyer model?

---

### What is the Rails way to then incorporate the other `belongs_to` relationships?

It's not a nested attribute (as the other objects already exist). 

### Should I be merging in the other params with something like?

```
params.require(:feedback).permit(:rating, :comment).merge(seller_id: @seller.id, listing_id: @listing.id)

```

---

One approach I have seen is the use of a `before_validation` filter in this sort of manner (from a different domain) like this:

```
class Feedback < ActiveRecord::Base
  belongs_to :user
  belongs_to :host, :class_name => "User"
  belongs_to :inquiry
  belongs_to :room

before_validation :set_room_and_guest_id

def set_room_and_guest_id
  self.room ||= self.inquiry.room if self.inquiry
  self.user ||= self.inquiry.user if self.inquiry
end

```

I have spent a long time reading related posts about this today as well as the Rails documentation and have not been able to find a conclusion.