Prashant Tiwari
2006-Mar-27 06:30 UTC
[Rails] Naming conventions for models on older database????
Hi, I am using RoR for my web development. But Database is already created (Older database) with its own table name without RoR Specificcations. Table names are:- blacklist_patterns category comment moderation store vote What will be names for models corresponding to my above tables? If I want to specify my own names to models? Can I do it? If yes then How? Please tell me. Thanx in advance. Prash -- Posted via http://www.ruby-forum.com/.
Wilson Bilkovich
2006-Mar-27 07:24 UTC
[Rails] Naming conventions for models on older database????
On 3/27/06, Prashant Tiwari <tiwari_p_k@yahoo.com> wrote:> Hi, > > I am using RoR for my web development. But Database is already created > (Older database) with its own table name without RoR Specificcations. > Table names are:- > blacklist_patterns > category > comment > moderation > store > vote > > What will be names for models corresponding to my above tables? If I > want to specify my own names to models? Can I do it? If yes then How? >You can name your models however you wish, and use the "set_table_name" method to specify this. class Comment < ActiveRecord::Base set_table_name ''comment'' end One further piece of trickery: currently, your unit test fixtures need to be named after the actual table, rather than after the model. So, put your comment fixtures in comment.yml, and refer to them with ''fixtures :comment''