I'd like to submit a product ID and a retailer ID to my controller, if that combo exisiting in the DB I want to update that record with the submitted params, if not, create a new record.
My controller is below and currently I can see that if the the combo does not exist the record is created but when the combo is found it does a select query and the record is not updated.
How can I get it to update and not just select?
Thanks
Controller:
def AddNewPrice
@newPrice = ProductPrice.find_or_create_by(product_id: params[:product_id], retailer_id: params[:retailer_id])
end
Update
Sorry..Just to mentioned, when I update I want to update the price attribute that comes in as a param