Guest User

Untitled

a guest
Jun 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. module Api
  2. module V1
  3. class IngredientMeasuresController < ApplicationController
  4.  
  5. def index
  6. render json: IngredientMeasure.all
  7. end
  8.  
  9. def create
  10. ingredient_measure = IngredientMeasure.new(params[:id_ingredient, :id_measure])
  11. if ingredient_measure.save
  12. render json: ingredient_measure
  13. else
  14. render json: {status: 500, err: 'Ingredient measure could not be created'}
  15. end
  16. end
  17. private
  18.  
  19. def ingredient_measure_params
  20. params.require(:ingredient_measure).permit(:ingredient_id, :measure_id)
  21. end
  22. end
  23. end
  24. end
  25.  
  26. {
  27. "measure_id" : 3,
  28. "ingredient_id":3
  29. }
Add Comment
Please, Sign In to add comment