Forum: Ruby on Rails Naming conventions for models on older database????

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8c70506408fddb9740b4de7339055c77?d=identicon&s=25 Prashant Tiwari (tiwaripk)
on 2006-03-27 08:30
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
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-03-27 09:24
(Received via mailing list)
On 3/27/06, Prashant Tiwari <tiwari_p_k@yahoo.com> wrote:
> 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'
This topic is locked and can not be replied to.