Skip to content

@vsavkin /book_user_address.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Book, User, Address
class Book
include DataMapper::Resource
property :id, Serial
property :title, String
property :author, String
property :price, Decimal
end
class User
include DataMapper::Resource
property :id, Serial
property :name, String
property :address_country, String
property :address_city, String
validates_presence_of :name
def address= address
self.address_country = address.country
self.address_city = address.city
end
def address
Address.new(address_country, address_city)
end
end
class Address < Struct.new(:country, :city)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.