On Feb 9, 2006, at 10:11 AM, Adam F. wrote:
You’re method puts you off the rails. The foreign key is misnamed
with respect to Rails’ naming conventions.Nope. Still called “id”.
Wrong column. I said the foreign key is misnamed.
There’s nothing that says a foreign key has to be called anything in
particular.Yes, when you set up the relations in rails, you need to override the
default names, but that’s expected behavior.
How can overriding default behavior be considered expected behavior?
Expected by who?
There’s nothing that says that you have to stick to the default naming
conventions, and there are plenty of exceptions. Doing so doesn’t “put
you off the rails”.
I completely, though respectfully, disagree.
Why do the extra work? Of what benefit is it to use your method, which
will cause extra work and more difficulty in comprehension for each and
every person who needs to work with the schema the Rails code in the
future?
Rails gives you the ability to override so that:
- People can’t complain and say “Rails is too restrictive”
- It will work with legacy schemas
- It’s flexible enough to handle really weird situations
What it does do, is make it simple in the beginning and particularly
in the future, if you just follow the conventions. It’s the difference
between the carrot and stick…
So, IMHO, while what you’re doing is technically supported, it’s
definitely
NOT on the Rails.
P.S. Did you know that you can write routes that will allow you to
direct
incoming requests to controllers with different names? Or that you
can use layouts and views that don’t match the controller names?
The framework is flexible enough to handle this, much as rope is
flexible enough to be used for many purposes, including hanging
oneself. I’m not suggesting there’s never a reason to do any
of the
things mentioned, but I am suggesting that there had better
be some
very good reasons to do so, or you’ve just created extra work
for
yourself, and for each and every person who will support your
app in
the future.
–
– Tom M.