Sha256: 5a3d690225444c0b0a7ebc2f63f87f55f9a7c1d186084c7b6599f0044c132ea7
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
class RailsTradeAdmin::CartItemServesController < RailsTradeAdmin::BaseController before_action :set_cart_item def index end def single end def total end def show end def new @cart_item_serve = @cart_item.cart_item_serves.find_or_initialize_by(serve_id: params[:serve_id]) @serve_charge = @cart_item.get_charge(@cart_item_serve.serve) end def create @cart_item_serve = @cart_item.cart_item_serves.find_or_initialize_by(serve_id: cart_item_serve_params[:serve_id]) @cart_item_serve.assign_attributes cart_item_serve_params @serve_charge = @cart_item.get_charge(@cart_item_serve.serve) @serve_charge.subtotal = @cart_item_serve.price respond_to do |format| if @cart_item_serve.save @cart_item.cart_item_serves.reload format.js format.html { redirect_to @cart_item_serve, notice: 'Taxon item was successfully created.' } else format.js format.html { render :new } end end end def add @cart_item_serve = @cart_item.cart_item_serves.find_or_initialize_by(serve_id: params[:serve_id]) @serve_charge = @cart_item.get_charge(@cart_item_serve.serve) @cart_item_serve.price = @serve_charge.default_subtotal @cart_item_serve.save end def destroy @cart_item_serve = CartItemServe.find(params[:id]) @serve_charge = @cart_item.get_charge(@cart_item_serve.serve) @cart_item_serve.destroy end private def set_cart_item @cart_item = CartItem.find params[:cart_item_id] end def cart_item_serve_params params.fetch(:cart_item_serve, {}).permit(:serve_id, :price) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_trade-0.0.1 | app/controllers/the_trade_admin/cart_item_serves_controller.rb |