Guest User

Untitled

a guest
Jan 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. def edit
  2. @product = Product.find(params[:id])
  3. end
  4.  
  5. def update
  6. # use update method
  7. @product = Product.find(params[:id])
  8.  
  9. # use update_attributes to update the record
  10. if @product.update_attributes(product_params)
  11. render json: { status: :ok, message: 'Product updated ', data: @product }
  12. else
  13. render json: { status: :error, message: 'Product not available', data: @product }
  14. end
  15. end
  16.  
  17. private
  18. def product_params
  19. params.require(:product).permit(:title, :price, :count)
  20. end
Add Comment
Please, Sign In to add comment