Sha256: d1822cde5f82b16a3e3e947fa9342a52865ae266c5c0877045fceaeddafd9141

Contents?: true

Size: 732 Bytes

Versions: 5

Compression:

Stored size: 732 Bytes

Contents

class BasketsController < ApplicationController

  
  include Restfulie::Server::ActionController::Base
  
  respond_to :xml, :json
  
  def create
    @basket = Basket.new
    params[:basket][:items].each do |item|
      puts item.class
      puts item[:id]
      @basket.items << Item.find(item[:id])
    end
    @basket.save
    render :text => "", :status => 201, :location => basket_url(@basket)
  end
  
  def update
    @basket = Basket.find(params[:id])
    params[:items].each do |item|
      @basket.items << Item.find(item[:id])
    end
    @basket.save
    render :text => "", :status => 201, :location => basket_url(@basket)
  end

  def show
    @basket = Basket.find(params[:id])
    respond_with @basket
  end


end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
restfulie-nosqlite-1.0.4 full-examples/rest_from_scratch/part_3/app/controllers/baskets_controller.rb
restfulie-1.1.1 full-examples/rest_from_scratch/part_3/app/controllers/baskets_controller.rb
restfulie-1.1.0 full-examples/rest_from_scratch/part_3/app/controllers/baskets_controller.rb
restfulie-nosqlite-1.0.3 full-examples/rest_from_scratch/part_3/app/controllers/baskets_controller.rb
restfulie-1.0.3 full-examples/rest_from_scratch/part_3/app/controllers/baskets_controller.rb