Sha256: f7c850c22fdb1b0e3489097e56056e532af17224e787c947e4549c45fc9751d3
Contents?: true
Size: 1.66 KB
Versions: 62
Compression:
Stored size: 1.66 KB
Contents
module Workarea module Admin class PricesController < Admin::ApplicationController required_permissions :catalog before_action :check_publishing_authorization before_action :find_sku before_action :find_price, except: [:index, :new] def index end def new end def create if @price.save flash[:success] = t('workarea.admin.prices.flash_messages.saved', sku: @sku.id) redirect_to pricing_sku_prices_path(@sku) else render :index, status: :unprocessable_entity end end def edit end def update if @price.update_attributes(price_params) flash[:success] = t('workarea.admin.prices.flash_messages.saved', sku: @sku.id) redirect_to pricing_sku_prices_path(@sku) else render :edit, status: :unprocessable_entity end end def destroy @price.destroy flash[:success] = t('workarea.admin.prices.flash_messages.deleted', sku: @sku.id) redirect_to pricing_sku_prices_path(@sku) end private def price_params # Blank strings convert to $0 when to_money is called (params[:price] || {}).transform_values(&:presence) end def find_sku @sku = PricingSkuViewModel.wrap( Pricing::Sku.find(params[:pricing_sku_id]) ) end def find_price @price = if params[:id].present? @sku.prices.find_or_create_by(id: params[:id]) else @sku.prices.build(price_params) end end end end end
Version data entries
62 entries across 62 versions & 1 rubygems