Anomaly on Rails model validation

Skip to first unread message

Tim Rowe

Jan 15, 2016, 12:51:21 PM1/15/16
I'm finding the behaviour of YARD puzzling on Rails models.
If I use validates on a member of a model, rails flags that member as an undocumented read-only attribute, and of course if I then put some markup on it then the markup comes out correctly in the documentation.

If I use a documentation helper, though, such as validates_length_of, YARD does not see it as an attribute, and so even if I mark it up it doesn't appear in the documentation.

The result of this is that I don't see attributes with simple validation (where I just use a relevant helper) don't get documented, only those with complex validation (where I use validates) do.

The workaround, I suppose, is not to use the helpers; to write:
# The name of the thing 
validates :name length: {maximum: 20}
instead of:
# The name of the thing
 validates_length_of :name, maximum: 20

but I wonder whether there's a way to get YARD to recognise those helpers as attributes? 

Reply all
Reply to author
0 new messages