Sha256: c6a049a1d7d06cc3ffd48715dcdf0eb98f9bace38d099bd46354111668297d29
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require_dependency "navinshop/application_controller" module Navinshop class ItemsController < ApplicationController before_action :set_item, only: [:show, :edit, :update, :destroy] # GET /items def index @items = Item.all end # GET /items/1 def show end # GET /items/new def new @item = Item.new @item.category_id=params[:category_id] end # GET /items/1/edit def edit end # POST /items def create @item = Item.new(item_params) if @item.save redirect_to @item, notice: 'Item was successfully created.' else render :new end end # PATCH/PUT /items/1 def update if @item.update(item_params) redirect_to @item, notice: 'Item was successfully updated.' else render :edit end end # DELETE /items/1 def destroy @item.destroy redirect_to items_url, notice: 'Item was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_item @item = Item.find(params[:id]) end # Only allow a trusted parameter "white list" through. def item_params params.require(:item).permit(:title, :text, :category_id, :image) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
navinshop-0.0.2 | app/controllers/navinshop/items_controller.rb |
navinshop-0.0.1 | app/controllers/navinshop/items_controller.rb |