Skip to content

Commit

Permalink
supporting full examples
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Aug 31, 2010
1 parent cea8416 commit c3c79f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Expand Up @@ -16,6 +16,15 @@ def create
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
Expand Down
2 changes: 2 additions & 0 deletions full-examples/rest_from_scratch/part_3/config/routes.rb
Expand Up @@ -6,6 +6,8 @@

resources :items

match "baskets/:id", :controller => :baskets, :action => :update, :conditions => {:method => :patch}

# The priority is based upon order of creation:
# first created -> highest priority.

Expand Down
Expand Up @@ -15,8 +15,9 @@ def self.run
Restfulie::Common::Logger.logger.level = Logger::ERROR
goal = BuyingProcess.new("Rest", "Calpis")
result = Restfulie::Mikyung.new.achieve(goal).run

result.response.code.should == 200
result.payment.price.should == "410.0"
result.payment.amount.should == 410.0
puts "Goal Achieved"
end
end

0 comments on commit c3c79f2

Please sign in to comment.