More validation problems with :accessible => true
Reported by Iain | August 5th, 2010 @ 06:59 AM | in Hobo 1.3 (Rails 3)
I've noticed that the fix to #447 is creating some inconsistent behaviour.
Say I have two models, A and B:
class A < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
end
has_many :bs, :accessible => true
end
class B < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
name :string
end
belongs_to :a
validates_format_of :name, :with => /^M/i # totally arbitrary
end
If you create a new A with several B's (using input-many for example) and any of the B's fail validation, then the hobo documentation says that there should be a "..." error in A (incidentally, the error-messages tag ignores "..." errors).
However, due to the fix to #447 (in Hobo::AccessibleAssociations.find_or_create_and_update), this doesn't happen when both the parent and the child are new records (if either already exist, it will work).
This is a bit annoying if you want to do interesting things with how you handle error messages.
Also, I've noticed that if the "..." error message does get raised, it's converted into the garbage error message below (I've tried it on two apps and with the same result) by the time it reaches DRYML, and because of this it isn't filtered out by the error-messages tag. The message is definitely "..." when it's saved into the model.errors enum but by the time it gets to the error-messages tag it's changed to the message below. If I change the code in hobo to make the message anything but "..." it doesn't get converted into this message and passes through to error-messages just fine.
emptycan't be emptyinvalidis invalidacceptedmust be acceptedless_thanmust be less than {{count}}wrong_lengthis the wrong length (should be {{count}} characters)exclusionis reservednot_a_numberis not a numbertakenhas already been takenless_than_or_equal_tomust be less than or equal to {{count}}too_shortis too short (minimum is {{count}} characters) blankcan't be blankoddmust be oddtoo_longis too long (maximum is {{count}} characters) greater_thanmust be greater than {{count}}confirmationdoesn't match confirmationevenmust be evengreater_than_or_equal_tomust be greater than or equal to {{count}}inclusionis not included in the listequal_tomust be equal to {{count}}record_invalidValidation failed: {{errors}}
These errors are occurring on hobo 1.0.1
Comments and changes to this ticket
-
Matt Jones September 15th, 2011 @ 06:20 PM
- State changed from new to open
- Milestone set to Hobo 1.3 (Rails 3)
- Milestone order changed from 197868 to 0
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป