# Hardcoding things related to data in the database

**URL:** <https://www.ruby-forum.com/t/hardcoding-things-related-to-data-in-the-database/70588>\
**Category:** Rails\
**Created:** [September 30, 2006, 6:16pm UTC](https://www.ruby-forum.com/t/hardcoding-things-related-to-data-in-the-database/70588 "2006-09-30T18:16:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 30, 2006, 6:16pm UTC](https://www.ruby-forum.com/t/hardcoding-things-related-to-data-in-the-database/70588/1 "2006-09-30T18:16:38Z")

</div>

Hi,  
What do people think about hardcoding stuff related to data in the  
database? Obviously, there are some things which you have no choice  
abnout, but where it can be avoided, should it? I would think so, but  
I don’t really have the experience to know if it really is something  
to avoid.

Let me give an example (albeit very vague) of what I mean. An object  
in your model can be type 1 or type 2 (stored in the ‘type’ field in  
the class’s table). One type requires one layout in the view, and  
another requires a completely different layout. Obviously this is one  
case where hardcoding can’t be avoided, which means that if you want  
to add a third type, you have to change your code. But if it can be  
avoided by, say, adding an extra two tables to your database, should  
you?

Hope you all understand what I mean.

-Nathan
