class LineItemsController

START:current_cart START:setup

Public Instance Methods

create() click to toggle source
POST /line_items
POST /line_items.json

START:create

# File app/controllers/line_items_controller.rb, line 36
  def create
    product = Product.find(params[:product_id])
    @line_item = @cart.add_product(product.id)

    respond_to do |format|
      if @line_item.save
        format.html { redirect_to store_url }
        format.js   { @current_item = @line_item }
        format.json { render :show,
          status: :created, location: @line_item }
      else
        format.html { render :new }
        format.json { render json: @line_item.errors,
          status: :unprocessable_entity }
      end
    end
  end
destroy() click to toggle source

DELETE /line_items/1 DELETE /line_items/1.json

# File app/controllers/line_items_controller.rb, line 73
def destroy
  @line_item.destroy
  respond_to do |format|
    format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }
    format.json { head :no_content }
  end
end
edit() click to toggle source

GET /line_items/1/edit

# File app/controllers/line_items_controller.rb, line 30
def edit
end
index() click to toggle source
GET /line_items

END:current_cart

GET /line_items.json
# File app/controllers/line_items_controller.rb, line 15
def index
  @line_items = LineItem.all
end
new() click to toggle source

GET /line_items/new

# File app/controllers/line_items_controller.rb, line 25
def new
  @line_item = LineItem.new
end
show() click to toggle source

GET /line_items/1 GET /line_items/1.json

# File app/controllers/line_items_controller.rb, line 21
def show
end
update() click to toggle source

PATCH/PUT /line_items/1 PATCH/PUT /line_items/1.json

# File app/controllers/line_items_controller.rb, line 59
def update
  respond_to do |format|
    if @line_item.update(line_item_params)
      format.html { redirect_to @line_item, notice: 'Line item was successfully updated.' }
      format.json { render :show, status: :ok, location: @line_item }
    else
      format.html { render :edit }
      format.json { render json: @line_item.errors, status: :unprocessable_entity }
    end
  end
end