Hi Perry,
Perry S. wrote:
What I want to do is create a table that has a unique id
and a string which will be the type. The other tables that
type will point to will have the same id and the attributes
for that type. So, the first table may be items and items
could reference people, companies, etc. The key
to people, companies, etc is the same id as for item – i.e. if you
union all of the sub tables, you will have each id at most one time.
Your description above contains much that we allow Rails and AR to
manage
for us. One of the key things with Rails is that primary keys are
meaningless to us. Only AR cares about them, and we let it take control
of
them to make it easier for us to focus on the application itself rather
than
the management of the data the app uses. You’ll find it a lot easier to
work with Rails, and to get help here too IME, if you can start by
answering: “From a user perspective, what problem are you solving? What
is
it you’re trying to allow the user to do with your application?”
I believe, using PostgreSQL’s features, this will be easier
to keep consistent. Of course, I may find out that I’m full
of BS.
I haven’t used PostgreSQL with Rails, but don’t have the impression from
seeing OP’s posts that it’s any easier or harder than any other
supported DB
with Rails.
But, part of the knowledge I need to gain is how ActiveRecord
goes from the blob of mess that the database returns to an instance
of a particular class.
Depending on exactly what your objective is, you may or may not need to
know
the above in order to achieve your objective. Probably not. In
general,
our apps deal in objects, we tell AR how the objects are related, it
handles
the ORM mapping, and we’re happy for it.
If anyone can help me out and tell me where to look,
etc, that would be much appreciated.
I’d start out by trying to regain my “beginner eyes.” Will R. said
“It’s not what we don’t know that hurts. It’s what we know that ain’t
true.”
To be successful with Rails, you’re probably going to do quite a bit of
‘unlearning.’ That’s just speculation on my part, based on a year and a
half of observation / participation here on the list.
There are a number of beginner tutorials out there. With all things
Rails,
Google is your friend. You may find it too elementary for you, but you
might want to start with:
hth,
bill