17. Code
class Asset < ActiveRecord::Base
attr_accessible :name,
:description
include DataDelegator
# the secret sauce!!!
end
class Video < Asset
attr_accessible :url
data_delegate :only=> [:url]
# moar secrets!!!
end
18. Alternatives
• HSTORE
– Supported by ActiveRecord > 4.0
– Can’t nest
• BATF
– Works with any data store
– Need to serialize
– Can’t manipulate or query in the DB
20. More Postgres + JSON
• Postgres can also serialize records
natively, returning a string of valid JSON.
– Does not require the instantiation of Ruby objects
– FAST
21. Even more
• You can installV8 in Postgres and write
custom query functions in Javascript
– Awesome
– Web developers are already familiar with it