Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def edit
- @product = Product.find(params[:id])
- end
- def update
- # use update method
- @product = Product.find(params[:id])
- # use update_attributes to update the record
- if @product.update_attributes(product_params)
- render json: { status: :ok, message: 'Product updated ', data: @product }
- else
- render json: { status: :error, message: 'Product not available', data: @product }
- end
- end
- private
- def product_params
- params.require(:product).permit(:title, :price, :count)
- end
Add Comment
Please, Sign In to add comment