Issue with #valid? and setting errors on tickets
Closed this issue · 1 comments
mjankowski commented
Im not sure if this an issue with activeresource or the lighthouse API, but here's what I see...
ree-1.8.7-2010.02 > ticket = Lighthouse::Ticket.new
=> #<Lighthouse::Ticket:0x1051a7308 @prefix_options={}, @attributes={}>
ree-1.8.7-2010.02 > ticket.valid?
=> true
ree-1.8.7-2010.02 > ticket.errors
=> #<OrderedHash {}>
ree-1.8.7-2010.02 > ticket.errors.add :base, 'this is an invalid ticket'
=> ["this is an invalid ticket"]
ree-1.8.7-2010.02 > ticket.valid?
=> true
ree-1.8.7-2010.02 > ticket.errors
=> #<OrderedHash {}>
ree-1.8.7-2010.02 > ticket = Lighthouse::Ticket.new
=> #<Lighthouse::Ticket:0x105194028 @prefix_options={}, @attributes={}>
ree-1.8.7-2010.02 > ticket.errors
=> #<OrderedHash {}>
ree-1.8.7-2010.02 > ticket.errors.add :base, 'this is an invalid ticket'
=> ["this is an invalid ticket"]
ree-1.8.7-2010.02 > ticket.errors
=> #<OrderedHash {:base=>["this is an invalid ticket"]}>
ree-1.8.7-2010.02 > ticket.valid?
=> true
ree-1.8.7-2010.02 > ticket.errors
=> #<OrderedHash {}>
I dug through activeresource a bit - it's #valid? method clears the errors, then runs callbacks to add them back in. Is this an issue with how lighthouse ticket is using that, or with ActiveResource itself?
mjankowski commented
I've asked on rails issues as well - https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6041-activeresource-validations