I have an action that saves new procucts as follows:
@products = Product.new(params[:product])
@products.save
I invoke the same action to edit the product. But every time I edit ... a new product is created (due to the above statements).
While before I saw some function that will create a new record only if there is no record. create_or_updatesomething like that. I can not find it now.
Can someone tell me what this method is? or give me a better approach for this?
source
share