START:current_cart START:setup
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 action: 'show', status: :created, location: @line_item } else format.html { render action: 'new' } format.json { render json: @line_item.errors, status: :unprocessable_entity } end end end
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 } format.json { head :no_content } end end
GET /line_items/1/edit
# File app/controllers/line_items_controller.rb, line 30 def edit end
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
GET /line_items/new
# File app/controllers/line_items_controller.rb, line 25 def new @line_item = LineItem.new end
GET /line_items/1 GET /line_items/1.json
# File app/controllers/line_items_controller.rb, line 21 def show end
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 { head :no_content } else format.html { render action: 'edit' } format.json { render json: @line_item.errors, status: :unprocessable_entity } end end end