[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

tables/field names in rails

Ike

10/15/2006 6:58:00 PM

Is anyone aware of something which would MAP the table & field names that
someone might presently use in a db schema, to the rails requirements? For
example, if I have a table called associate, and a table called users, and
within associates, I have a field called userskey which contains the id in
users, I would like to be able to map what these table and field names ARE
to what they SHOULD be to comport with the rails naming conventions (i.e.
the tables should be associates, users and the field in question should be
users_id).

Is anyone aware of such a mapping mechanism? It seems this is a mature
enough web platform that such a mechanism must exist (in which case, the
Struts and JSF holdouts would HAVE to come along!)

Thanks, Ike


3 Answers

Eric Hodel

10/15/2006 9:20:00 PM

0

I think this is a question for the Rails mailing list.

--
Eric Hodel - drbrain@segment7.net - http://blog.se...
This implementation is HODEL-HASH-9600 compliant

http://trackmap.rob...



David Vallner

10/15/2006 9:38:00 PM

0

Ike wrote:
> Is anyone aware of something which would MAP the table & field names that
> someone might presently use in a db schema, to the rails requirements?

Random googlage shows http://the.rubydevelopers.n....

If you have control over the database, you could also go the other way
around: create a separate schema called, lessay, "rails", consisting of
only views that would alias the original names to the Rails-friendly ones.

This, of course, presumes that the database can do that.

David Vallner

Ben Bleything

10/15/2006 9:51:00 PM

0

On Mon, Oct 16, 2006, Ike wrote:
> Is anyone aware of something which would MAP the table & field names that
> someone might presently use in a db schema, to the rails requirements? For
> example, if I have a table called associate, and a table called users, and
> within associates, I have a field called userskey which contains the id in
> users, I would like to be able to map what these table and field names ARE
> to what they SHOULD be to comport with the rails naming conventions (i.e.
> the tables should be associates, users and the field in question should be
> users_id).

ActiveRecord is very flexible, it just supposes "sensible" defaults.
You can easily use it with legacy schema that don't fit the naming
scheme.

See, for example, ActiveRecord::Base#set_table_name, #set_primary_key,
and friends.

Ben