# Semantic Meaning in ActiveRecord Attributes

**URL:** <https://www.ruby-forum.com/t/semantic-meaning-in-activerecord-attributes/126491>\
**Category:** Rails\
**Created:** [January 18, 2008, 6:29pm UTC](https://www.ruby-forum.com/t/semantic-meaning-in-activerecord-attributes/126491 "2008-01-18T18:29:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 18, 2008, 6:29pm UTC](https://www.ruby-forum.com/t/semantic-meaning-in-activerecord-attributes/126491/1 "2008-01-18T18:29:57Z")

</div>

Hello,

My problem:

Attributes in ActiveRecord have no semantic meaning. And the  
attributes are defined in the db making it difficult to attach  
semantic meaning in the db level (without making things complicated in  
the schema)

I want to associate very simple semantic/metadata information to  
attributes of models, without having to  
put all the fields in the db into the Model file. As this feels like  
its breaking the DRY principle (and making Rails models less clean and  
agile).

I’ve looked at Django and how it deals with meta data and models and  
I’m wishing I could do something similar in Rails. See my descriptions  
here ([http://www.joesniff.co.uk/critique/automatic-admin-systems-](http://www.joesniff.co.uk/critique/automatic-admin-systems-)  
semantics-with-rails-and-django.html)  
Ultimately its models are defined in Python objects and mapped down to  
db types, so metadata is easy to attach.

I want to try and achieve something like:

Database → Polls{Id Integer(11), monkeyZipcode Char(12)}

And in the Polls Model metadata in the model indicating that  
‘monkeyZipcode’ is a zipcode rather than just a char(12).

I’ve thought about:  
\*Representing meta data in the database about the database 🙂  
\*Inferring semantic meaning from the name of model attributes fields

There does look like some promising projects currently going in in  
Rails:  
[http://code.google.com/p/semanticattributes/](http://code.google.com/p/semanticattributes/)

Have other people tried to deal with this problem?

Any thoughts highly appreciated.

Thanks,  
Joseph W.  
[http://www.joesniff.co.uk/](http://www.joesniff.co.uk/)
