Line item confusion

I am trying to create a search engine that will save an item of a user into a line item.

When the user searches inside his home page(localhost/user/3)

each item displayed in the search has a button link to add to the line item

how do i tell the item to add the product_id to the user_id in the line item??

{{code}}

line_item

belongs_to :user_id(foreign key) belongs_to :product_id(foreign key)