Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

copyhacker opened this issue Jun 27, 2011 · 3 comments

Comments

@copyhacker
Copy link

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.

@spraints
Copy link

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) 

@mmack
Copy link

mmack commented Aug 15, 2011

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

@mmack
Copy link

mmack commented Aug 18, 2011

Ok, here it is: dozeo@0ff2323

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants