Sha256: 289230c9ab1cf23dfec1571be319fa76e32f644a49480c0b320012860e33ba75
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
module Admin class WinemakersController < Fae::ApplicationController before_action :set_item, only: [:show, :edit, :update, :destroy] layout false, except: :index helper Fae::ApplicationHelper def new @item = Winemaker.new @item.wine_id = params[:item_id] build_assets end def edit build_assets end def create @item = Winemaker.new(permitted_params) if @item.save @parent_item = @item.wine flash[:notice] = 'Item successfully created.' render template: 'admin/winemakers/table' else build_assets render action: 'new' end end def update if @item.update(permitted_params) @parent_item = @item.wine flash[:notice] = 'Item successfully updated.' render template: 'admin/winemakers/table' else build_assets render action: 'edit' end end def destroy @parent_item = @item.wine if @item.destroy flash[:notice] = 'Item successfully removed.' else flash[:alert] = 'There was a problem removing your item.' end render template: 'admin/winemakers/table' end private def set_item @item = Winemaker.find(params[:id]) end def permitted_params params.require(:winemaker).permit! end def build_assets @item.build_winemaker_image if @item.winemaker_image.blank? end end end
Version data entries
3 entries across 3 versions & 1 rubygems