Sha256: cf0706a8837d3eee8476c89e6de89bdd8266ff7424aaba0677b64b8bd6f47097
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
class OrdersController < ApplicationController before_action :set_order, only: %i[show edit update destroy] def self.class_method "just for testing purposes" end # GET /orders def index @orders = Order.all end # GET /orders/1 def show end # GET /orders/new def new @order = Order.new end # GET /orders/1/edit def edit end # POST /orders def create @order = Order.new(order_params) if @order.save redirect_to @order, notice: "Order was successfully created." else render :new, status: :unprocessable_entity end end # PATCH/PUT /orders/1 def update if @order.update(order_params) redirect_to @order, notice: "Order was successfully updated.", status: :see_other else render :edit, status: :unprocessable_entity end end # DELETE /orders/1 def destroy @order.destroy! redirect_to orders_url, notice: "Order was successfully destroyed.", status: :see_other end private # Use callbacks to share common setup or constraints between actions. def set_order @order = Order.find(params[:id]) end # Only allow a list of trusted parameters through. def order_params params.require(:order).permit(:name, :qty) end end
Version data entries
3 entries across 3 versions & 1 rubygems