SemanticAttributes
From WhyNotWiki
| Rating: | ![]() |
|---|---|
| Categories/Tags: | [Validations (category)][ActiveRecord / Attributes (category)]
|
| Project/Development: | http://code.google.com/p/semanticattributes/
|
| Description: | Provides meaningful model attributes for the Ruby on Rails world.
|
| Authors: | Lance Ivy |
| Readiness: | not even in beta
|
http://code.google.com/p/semanticattributes/.
ActiveRecord's attributes are not very friendly to programs that want to automatically and intelligently adapt behavior based on column types. Even once the dev has added validations to the attributes, other plugins are unable to reflect on the attributes and customize their behavior.The basic problem is that attributes in ActiveRecord have no semantic meaning. Validations only describe what to do with a field, not what the field means. But if you know what the field means, then you (and other plugins) can easily infer what to do! So the built-in validations are really tackling the problem backwards.
It sounds impossible to describe the meaning every attribute may have, but if we accept the 80/20 guideline then we can package up 20% of the descriptions that classify 80% of the attributes, and provide a way for devs to build the rest as needed.
Consider how common the following fields are:
- phone number
- email address
- url
- filename
- zip code
- us_state
Given semantically meaningful descriptions of these (and other) fields, we can not only automatically generate validation logic but also provide methods for standard database/human formatting and provide a reflection API for other plugins (e.g. ActiveScaffold).
Some work has been done in this field already, but the other projects don't seem to realize their entire potential. For comparison, see:

