The following inserts a new product, no problem. Howeve, I have to prefix the filename with "\images\" so upon retrieval it will looki in the right directory.
How can I modify this code to append "\images\" to the filename column?
def create
@product = Product.new(@params[:product])
if @product.save
flash['notice'] = 'Product was successfully created.'
end
end
def create
@product = Product.new(@params[:product])
@product.filename = "\\images\\" + @product.filename
if @product.save
flash['notice'] = 'Product was successfully created.'
end
end
This approach might be problematic if you're creating new products in other
actions or elsewhere in your rails app. Using before_save won't pose the same
problem.