I want to create a helper method for automatically displaying text fields with the maxlength attribute. I want this maxlegth to be set based on: max specified in the attributes of the validates_length field in order to remain DRY.
My question is: is there a good way to check the checks that are present in the attribute of the objects, and then extract the maximum length from this check.
I also plan on extracting other things, such as regex, from validates_format, so I can set the attribute in a text box, which js can then use to validate on the client side.
Thanks.
Reward Points: Why doesn't Rails automatically add maxlength to text fields for us?
source share