Sha256: 5035bf715a94b9ff457e5b3aa88b997bca2f5cf10dcccb059564a02b3474f05e
Contents?: true
Size: 1.81 KB
Versions: 5
Compression:
Stored size: 1.81 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 or /orders.json def index @orders = Order.all end # GET /orders/1 or /orders/1.json def show end # GET /orders/new def new @order = Order.new end # GET /orders/1/edit def edit end # POST /orders or /orders.json def create @order = Order.new(order_params) respond_to do |format| if @order.save format.html { redirect_to @order, notice: "Order was successfully created." } format.json { render :show, status: :created, location: @order } else format.html { render :new, status: :unprocessable_entity } format.json { render json: @order.errors, status: :unprocessable_entity } end end end # PATCH/PUT /orders/1 or /orders/1.json def update respond_to do |format| if @order.update(order_params) format.html { redirect_to @order, notice: "Order was successfully updated." } format.json { render :show, status: :ok, location: @order } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @order.errors, status: :unprocessable_entity } end end end # DELETE /orders/1 or /orders/1.json def destroy @order.destroy respond_to do |format| format.html { redirect_to orders_url, notice: "Order was successfully destroyed." } format.json { head :no_content } end 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
5 entries across 5 versions & 1 rubygems