Validation incompatible with ActiveModel::Errors in Rails 3.1
copyhacker opened this issue · comments
ActiveModel::Errors no longer subclasses OrderedHash as of 3.1:
hhttps://github.com/rails/rails/commit/307e6b2b74ba3ae72602dc33e6d45cd3e46181c7#activemodel/lib/active_model/errors.rb
Thus #each_pair is no longer implemented and CouchPotato::Database#valid_document? raises a NoMethodError.
I'll investigate a fix when I get a chance but wanted to go ahead and raise the flag.
This may be a change in 3.1.rc5, but save_document appears to hang when there are validation errors on a document.
class ThingA
include CouchPotato::Persistence
property :title
validates :title, :presence => true
end
CouchPotato.database.save_document(ThingA.new)
puts "This is never printed."
When I step through with rdb, it gets stuck in CouchPotato::Database#valid_document?... here's a snippet from rdb:
/Users/matt/dev/crankapps/.bundled/ruby/1.9.1/bundler/gems/couch_potato-0d7bf6efa7a8/lib/couch_potato/database.rb:174
v.each {|message| document.errors.add(k, message)}
(rdb:1) p v
["can't be blank", "can't be blank", "can't be blank"]
(rdb:1) n
/Users/matt/dev/crankapps/.bundled/ruby/1.9.1/bundler/gems/couch_potato-0d7bf6efa7a8/lib/couch_potato/database.rb:174
v.each {|message| document.errors.add(k, message)}
(rdb:1) p v
["can't be blank", "can't be blank", "can't be blank", "can't be blank"]
(rdb:1)
I have the same problem. Maybe i hack together something tomorrow.
Ok, here it is: dozeo@0ff2323
We need to discuss this problem:
dozeo@0ff2323#L2R41