CouchDB on Rails (6 of ?) Revision 10ef282cff47 (Tue Dec 16 2008 at 17:00) - Diff Link to this snippet: https://friendpaste.com/4VknN8S8AqXn2oZNgZAayj Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 123456789101112131415161718192021# Dynamically defining properties>> class Mocha < RelaxDB::Document; end>> Mocha.new.save>> m = Mocha.new>> m.class.instance_eval { property :shot }>> m.shot = "strong">> m.save>> Mocha.all=> [#<Mocha:9738370, _id: "779", _rev: "3750419526", shot: "strong">, #<Mocha:9729290, _id: "883", _rev: "2014351092">]# Dynamically defining properties - another approachMocha.module_eval { property :chilled }# Parameterizing a view request@cds = Cd.all.sorted_by(:year_of_release) { |q| q.startkey(2005).descending(true) }# Updating and saving@cd.set_attributes(params[:cd])# The following might be a little more succinct, but# you'd need to pass the document revision to the web clientCd.new(params[:cd]).save