START:setup START:setup
POST /carts POST /carts.json
# File app/controllers/carts_controller.rb, line 33 def create @cart = Cart.new(cart_params) respond_to do |format| if @cart.save format.html { redirect_to @cart, notice: 'Cart was successfully created.' } format.json { render action: 'show', status: :created, location: @cart } else format.html { render action: 'new' } format.json { render json: @cart.errors, status: :unprocessable_entity } end end end
DELETE /carts/1 DELETE /carts/1.json
START:destroy
# File app/controllers/carts_controller.rb, line 64 def destroy @cart.destroy if @cart.id == session[:cart_id] session[:cart_id] = nil respond_to do |format| format.html { redirect_to store_url } format.json { head :no_content } end end
GET /carts/1/edit
# File app/controllers/carts_controller.rb, line 28 def edit end
GET /carts
END:setup
GET /carts.json
# File app/controllers/carts_controller.rb, line 13 def index @carts = Cart.all end
GET /carts/new
# File app/controllers/carts_controller.rb, line 23 def new @cart = Cart.new end
GET /carts/1 GET /carts/1.json
# File app/controllers/carts_controller.rb, line 19 def show end
PATCH/PUT /carts/1 PATCH/PUT /carts/1.json
# File app/controllers/carts_controller.rb, line 49 def update respond_to do |format| if @cart.update(cart_params) format.html { redirect_to @cart, notice: 'Cart was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @cart.errors, status: :unprocessable_entity } end end end