working on proxy association and handling

This commit is contained in:
Sam Lown 2011-04-04 01:10:31 +02:00
parent 363461fc9d
commit 8fa7e87019
5 changed files with 75 additions and 67 deletions

View file

@ -15,7 +15,8 @@ module CouchRest
def validate_each(document, attribute, value)
view_name = options[:view].nil? ? "by_#{attribute}" : options[:view]
model = document.model_proxy || @model
model = (respond_to?(:model_proxy) && model_proxy ? model_proxy : @model)
# Determine the base of the search
base = options[:proxy].nil? ? model : document.instance_eval(options[:proxy])
@ -30,7 +31,7 @@ module CouchRest
unless document.new?
return if docs.find{|doc| doc['id'] == document.id}
end
if docs.length > 0
document.errors.add(attribute, :taken, options.merge(:value => value))
end