module ButtermilkBiscuits::RecipesController

Public Instance Methods

recipes_create_action() click to toggle source
# File lib/buttermilk_biscuits.rb, line 20
def recipes_create_action
  client_params = recipes_new_form
  json_data = post_request("/recipes", client_params)

  if !json_data["errors"]
    recipe = Recipe.new(json_data)
    recipes_show_view(recipe)
  else
    errors = json_data["errors"]
    recipes_errors_view(errors)
  end
end
recipes_destroy_action() click to toggle source
# File lib/buttermilk_biscuits.rb, line 50
def recipes_destroy_action
  input_id = recipes_id_form
  json_data = delete_request("/recipes/#{input_id}")
  puts json_data["message"]
end
recipes_index_action() click to toggle source
# File lib/buttermilk_biscuits.rb, line 6
def recipes_index_action
  recipe_hashs = get_request("/recipes")
  recipes = Recipe.convert_hashs(recipe_hashs)
  recipes_index_view(recipes)
end
recipes_show_action() click to toggle source
# File lib/buttermilk_biscuits.rb, line 12
def recipes_show_action
  input_id = recipes_id_form
  recipe_hash = get_request("/recipes/#{input_id}")
  recipe = Recipe.new(recipe_hash)

  recipes_show_view(recipe)
end
recipes_update_action() click to toggle source
# File lib/buttermilk_biscuits.rb, line 33
def recipes_update_action
  input_id = recipes_id_form
  recipe_hash = get_request("/recipes/#{input_id}")
  recipe = Recipe.new(recipe_hash)

  client_params = recipes_update_form(recipe)
  json_data = patch_request("/recipes/#{input_id}", client_params)

  if !json_data["errors"]
    recipe = Recipe.new(json_data)
    recipes_show_view(recipe)
  else
    errors = json_data["errors"]
    recipes_errors_view(errors)
  end
end