Created
April 30, 2011 00:43
-
-
Save albertoleal/949289 to your computer and use it in GitHub Desktop.
Couch Rest model - error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
shop2 = ShoppingCoupon.new(:name => 'Shop', :description =>"Clothes", | |
:items => [{:name => 'shirt', :price => 2.50}, {:name => 'pants', :price => 5}], | |
:purchased =>2011/03/21, :amount => 43.2) | |
shop2.save | |
=end | |
class ShoppingCoupon < CouchRest::Model::Base | |
use_database CouchServer.default_database | |
property :name, String | |
property :description, String | |
property :items do | |
property :name, String | |
property :price, Float | |
end | |
property :purchased, DateTime | |
property :amount, Float | |
timestamps! | |
end | |
Result: | |
ruby-1.9.2-head :001 > shop2 = ShoppingCoupon.new(:name => 'Shop', :description =>"Clothes", :items => [{:name => 'shirt', :price => 2.50}, {:name => 'pants', :price => 5}],:purchased =>2011/03/21, :amount => 43.2) | |
=> {"name"=>"Shop", "description"=>"Clothes", "price"=>nil, "items"=>[{}, {}], "purchased"=>31, "amount"=>43.2, "updated_at"=>nil, "created_at"=>nil, "couchrest-type"=>"ShoppingCoupon"} | |
ruby-1.9.2-head :002 > shop2.save | |
=> {"name"=>"Shop", "description"=>"Clothes", "price"=>nil, "items"=>[{}, {}], "purchased"=>31, "amount"=>43.2, "updated_at"=>2011-04-29 21:41:20 -0300, "created_at"=>2011-04-29 21:41:20 -0300, "couchrest-type"=>"ShoppingCoupon", "_id"=>"f212a7d0dbb0a32bf258ce84205eb152", "_rev"=>"1-44e7ff592310280a4cbb2ecacbc81945"} | |
ruby-1.9.2-head :003 > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fugly console post from my latest branch:
ruby-1.9.2-p180 :023 > class ShoppingCoupon < CouchRest::Model::Base
ruby-1.9.2-p180 :024?> property :name, String
ruby-1.9.2-p180 :025?> property :description, String
ruby-1.9.2-p180 :026?>
ruby-1.9.2-p180 :027 > property :items do
ruby-1.9.2-p180 :028 > property :name, String
ruby-1.9.2-p180 :029?> property :price, Float
ruby-1.9.2-p180 :030?> end
ruby-1.9.2-p180 :031?>
ruby-1.9.2-p180 :032 > property :purchased, DateTime
ruby-1.9.2-p180 :033?> property :amount, Float
ruby-1.9.2-p180 :034?>
ruby-1.9.2-p180 :035 > timestamps!
ruby-1.9.2-p180 :036?> end
=> [ShoppingCoupon]
ruby-1.9.2-p180 :037 > shop2 = ShoppingCoupon.new(:name => 'Shop', :description =>"Clothes",
ruby-1.9.2-p180 :038 > :items => [{:name => 'shirt', :price => 2.50}, {:name => 'pants', :price => 5}],
ruby-1.9.2-p180 :039 > :purchased =>2011/03/21, :amount => 43.2)
=> {"name"=>"Shop", "description"=>"Clothes", "items"=>[{"name"=>"shirt", "price"=>2.5}, {"name"=>"pants", "price"=>5.0}], "purchased"=>31, "amount"=>43.2, "updated_at"=>nil, "created_at"=>nil, "model"=>"ShoppingCoupon"}
ruby-1.9.2-p180 :040 > shop2.save
=> {"name"=>"Shop", "description"=>"Clothes", "items"=>[{"name"=>"shirt", "price"=>2.5}, {"name"=>"pants", "price"=>5.0}], "purchased"=>31, "amount"=>43.2, "updated_at"=>2011-04-30 01:00:19 UTC, "created_at"=>2011-04-30 01:00:19 UTC, "model"=>"ShoppingCoupon", "_id"=>"08f5c6af80735b6b5db8ada16bbc97cf", "_rev"=>"1-4563442f56af38096a19291f00673221"}