Данный метод из Mustache.rb Context # find :
def find(obj, key, default = nil)
hash = obj.respond_to?(:has_key?)
if hash && obj.has_key?(key)
obj[key]
elsif hash && obj.has_key?(key.to_s)
obj[key.to_s]
elsif !hash && obj.respond_to?(key)
meth = obj.method(key) rescue proc { obj.send(key) }
if meth.arity == 1
meth.to_proc
else
meth[]
end
else
default
end
rescue Exception => e # I added this to give the debugging output below
debugger
# ... see debug output below
raise
end
Может кто-нибудь объяснить, почему я получаю SecurityError Exception: calling insecure method: foo_id
, учитывая следующее:
obj #=> #<MyModel id: 1, foo_id: 3 ...> (an ActiveRecord object)
# Note foo_id is a column in the DB (a method defined by AR)
key #=> :foo_id
obj.tainted? #=> false
obj.method(key) #=> #<Method: MyModel#foo_id>
obj.send(key) #=> 3
obj.method(key)[] #=> raises "SecurityError Exception: calling insecure method: foo_id"
obj.method(key).tainted? #=> true... WTF?
Что я должен знать о obj.method(key)
и obj.method(key).call
?