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!)
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.
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.