Sha256: eb37aa72f809a102c7e9b89155a13592fd488498616c049e9124110f7c15c6bf

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

class Shoppe::DeliveryServicePricesController < Shoppe::ApplicationController

  before_filter { @active_nav = :delivery_services }
  before_filter { @delivery_service = Shoppe::DeliveryService.find(params[:delivery_service_id])}
  before_filter { params[:id] && @delivery_service_price = @delivery_service.delivery_service_prices.find(params[:id])}
  
  def index
    @delivery_service_prices = @delivery_service.delivery_service_prices.ordered
  end
  
  def new
    @delivery_service_price = @delivery_service.delivery_service_prices.build
  end
  
  def create
    @delivery_service_price = @delivery_service.delivery_service_prices.build(safe_params)
    if @delivery_service_price.save
      redirect_to [@delivery_service, :delivery_service_prices], :notice => "Price has been created successfully"
    else
      render :action => "new"
    end
  end
  
  def update
    if @delivery_service_price.update(safe_params)
      redirect_to [@delivery_service, :delivery_service_prices], :notice => "Price has been updated successfully"
    else
      render :action => "edit"
    end
  end
  
  def destroy
    @delivery_service_price.destroy
    redirect_to [@delivery_service, :delivery_service_prices], :notice => "Price has been removed successfully"
  end
  
  private
  
  def safe_params
    params[:delivery_service_price].permit(:price, :cost_price, :tax_rate_id, :min_weight, :max_weight, :code, :country_ids => [])
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shoppe-0.0.14 app/controllers/shoppe/delivery_service_prices_controller.rb
shoppe-0.0.13 app/controllers/shoppe/delivery_service_prices_controller.rb