> If you were to use parent_id as the field name, which would be more
> conventional and arguably more intuitive, then topic.parent_id would
> give you the id and topic.parent would give you the object.

I agree with you that the use of 'parent_id' for the foreign field
would have been a much better choice for a variety of reasons
including those that you cite.  The thing is that the use of
acts_as_tree came along late in the game long after the database had
been setup and long after a lot of code had already been written based
on that field being named 'parent'.  So, I just thought that since
acts_as_tree allows me to designate a foreign field with a name other
than the default, the easy thing to do would be to just make the
foreign field, 'parent' so that it would mesh with the existing
database.  I had no idea that it was going to open Pandora's Box.

Having said all of that, the thing that really grabed me about your
comment is this:

> then topic.parent_id would
> give you the id and topic.parent would give you the object.

Why would topic.parent give me the object?  Is that an acts_as_tree
thing?  I thought all acts_as_tree did was add the 3 methods,
'ancestors', 'root', and 'siblings'.  As far as I know, 'parent' is
not a reserved word in Ruby.  However, based on what you say, it would
seem that the choice of 'parent' as the field name may be an
*EXTREMELY* poor choice (even worse than I had thought).  Perhaps I
would have been better off if it had been named 'dad' or 'mom' or
something.  Anyway, I won't know the answer to that until I understand
why topic.parent would return the object.  May I impose on you a bit
further to tell me why that is.  Based on your answer, I may be FORCED
to change the name of that field.

Thanks a lot.

          ... doug

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to