【发布时间】:2011-09-06 11:11:56
【问题描述】:
这给了我一个错误 {"assertion"=>"map invoke failed: JS Error: ReferenceError: foo is not defined nofile_b:4"。有什么想法吗?
class ObjResults
include Mongoid::Document
field :foo, :type => Boolean, :default => false
field :bar, :type => Boolean, :default => false
def self.stats_by_user_id user_id
map = <<-MAP
function() {
if (this.user_id == "#{user_id}") {
hsh = {}
if (this.foo) {
hsh["foo"] = this.foo
}
if (this.bar) {
hsh["bar"] = this.bar
}
emit(this.user_id, hsh);
}
}
MAP
【问题讨论】:
标签: javascript ruby-on-rails ruby mongodb mapreduce