Forum: Ruby on Rails default database schema and relationships

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B262830cd2314f50e51d0b33ac7e32c1?d=identicon&s=25 arigold (Guest)
on 2007-02-13 01:59
(Received via mailing list)
hi everyone..

i'm a high school teacher who wrote a webapp in PHP and MySQL for my
curriculum.. i use it to keep attendance, take notes per student or
class and keep track of activities.  i would like to soup it up and
have read both the pickax and version 2 of agile web dev...

now i'm starting to work and i'd like to rename columns and
relationships in the database so that when i create rails
functionality to work with the database i can use the same database.
yep, i dont want to copy the data to a new database and have two apps
and two databases but its live - im using it daily.  i'd like to
slowly move the functionality to the rails app and eventually just
archive the PHP one.  but before i do that i have to switch my primary
keys to the rails defaults and the join tables and all that jazz to
the rails defaults..

i'm not worried about the data because i back it up and if all else
fails i'll just do the ol' INSERT INTO or UPDATE commands in terminal.

all that being said (phew) are the different defaults for rails in
terms of column types (id type, etc) and singular plural conventions
kept in one place somewhere?  has anyone made a list?  ive searched
the web quite a bit and was going to start going through v2 of agile
web dev but i thought i'd try an email before i got too into it..

sorry for the long background but i thought it best to be thorough..

Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-02-13 06:08
(Received via mailing list)
arigold wrote:

> i'm a high school teacher

Don't you mean "i ARE a high school teacher"? ;-)

> have read both the pickax and version 2 of agile web dev...

Grab /Rails Recipes/, by Chad Fowler, and hie thee hence to page 73,
"Integrating with Legacy Databases". The shortest answer is you must
using all the defaults that you currently leave out of the ActiveRecord
calls. Google for ActiveRecord::Base.set_primary_key or
for a preview.

  Phlip <-- NOT a blog!!!
B262830cd2314f50e51d0b33ac7e32c1?d=identicon&s=25 arigold (Guest)
on 2007-02-14 01:35
(Received via mailing list)
thank you philip..

dont quite get the "i ARE a high school teacher" joke but maybe thats
because i just got home and had back to back 10th and 9th graders.
maybe, just maybe 14 - 16 year olds arent biologically able to be
focused after 8 hours of school.. hmm.. ; )

i just might get that rails recipes book but from your short answer i
dont think that it answers my question.  it seems like you're looking
to bend rails to the legacy database.  i want to - yes its true - bend
the legacy database to rails' defaults.  i want to change the ID
column from "student_id" to "id".  actually, ive done that one
already.. im wondering what other things i'll need to change in the
legacy database to make it comply with the rails defaults.

any ideas?

in any event, thanks for pointing that book out..

all the best..~ari
18d8b0c948dd7b3d39c9667cfd4e817c?d=identicon&s=25 Andrew Stone (astone)
on 2007-02-14 01:47
(Received via mailing list)
> kept in one place somewhere?  has anyone made a list?  ive searched

I don't know if there is a list, but if someone else knows, that would
be a
good resource to share.  I would recommend using and
looking at the following relationships (listed in the lower left pane):


I think all give notes on database structure.


Andrew Stone
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-02-14 16:39
(Received via mailing list)
arigold wrote:

> dont quite get the "i ARE a high school teacher" joke

You were permitting sloppy grammar...

> ...comply with the rails defaults...

Rails practices "Convention over Configuration". Those are not
defaults they are conventions, and if you convene or configure Rails
differently, it will obey.

Your best bet would be a combination of that chapter in /Rails
Recipes/ and database migrations. Pick whichever is easiest, for each
detail of non-compliance.

Cba8c8adc11ee1152eb6f15ab7071511?d=identicon&s=25 werdnativ (Guest)
on 2007-02-14 17:42
(Received via mailing list)
Here's a helpful blog post I found titled "making a web app rewrite

This topic is locked and can not be replied to.