Validation incompatible with ActiveModel::Errors in Rails 3.1 #40

Closed
copyhacker opened this Issue Jun 27, 2011 · 3 comments

Comments

Projects
None yet
4 participants

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) 
Contributor

mmack commented Aug 15, 2011

I have the same problem. Maybe i hack together something tomorrow.

Contributor

mmack commented Aug 18, 2011

Ok, here it is: dozeo/couch_potato@0ff2323

We need to discuss this problem:
dozeo/couch_potato@0ff2323#L2R41

langalex closed this Sep 27, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment