Sha256: 65db7ce217a70427e798765cd08d917f07b9f0489e21341033f7fe788c8c624a
Contents?: true
Size: 1.32 KB
Versions: 7
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true # Controller for Ingredients, like "Mushrooms" class IngredientsController < ApplicationController before_action :set_ingredient, only: %i[show edit update destroy] # GET /ingredients def index @ingredients = Ingredient.all end # GET /ingredients/1 def show; end # GET /ingredients/new def new @ingredient = Ingredient.new end # GET /ingredients/1/edit def edit; end # POST /ingredients def create @ingredient = Ingredient.new(ingredient_params) if @ingredient.save redirect_to @ingredient, notice: 'Ingredient was successfully created.' else render :new end end # PATCH/PUT /ingredients/1 def update if @ingredient.update(ingredient_params) redirect_to @ingredient, notice: 'Ingredient was successfully updated.' else render :edit end end # DELETE /ingredients/1 def destroy @ingredient.destroy redirect_to ingredients_url, notice: 'Ingredient was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_ingredient @ingredient = Ingredient.find(params[:id]) end # Only allow a list of trusted parameters through. def ingredient_params params.require(:ingredient).permit(:name, :description, :aisle, :store, :cost) end end
Version data entries
7 entries across 7 versions & 1 rubygems