Is HABTM Dying?

For a while, I’ve been getting that HMT is replacing HABTM. It appears
that
HMT can do all of what HABTM can do and more. The question is: Should I
stop
using HABTM? Let’s take a simple case:

A case has many categories
For a given category, there are certain valid statuses

Category
has_and_belongs_to_many :statuses

Status
has_and_belongs_to_many :categories

Question:

Is there value associated with creating the join model to implement HMT
for
something this simple? I’m asking because it seems HABTM is on the
endangered features list.

Thanks

View this message in context:
http://www.nabble.com/Is-HABTM-Dying--t1733210.html#a4709495
Sent from the RubyOnRails Users forum at Nabble.com.

On 6/4/06, s.ross [email protected] wrote:

Status
has_and_belongs_to_many :categories

Question:

Is there value associated with creating the join model to implement HMT for
something this simple? I’m asking because it seems HABTM is on the
endangered features list.

Thanks

I use both HABTM and Has-Many-Through (HMT) depending on what “feels”
right. In the strictly many-to-many case, such as seems to be in your
example, I see no problem with sticking with HABTM. HTM is typically
important when there is a value in having a real abstraction for the
“middle” object (from which you can hook other relations and enforce
validations).

In any case, HTM and HABTM are not mutually exclusive, and I like
having both of them around; I see no reason for eliminating HABTM (not
to mention this would break compatibility with older Rails apps in a
pretty serious way). I don’t think HABTM is “endagered.”

Check this out:
http://blog.hasmanythrough.com/articles/2006/04/20/many-to-many-dance-off

Does a fantastic job of explaining the differences and similarities.
HABTM aint dying, IMO.

Joe

I don’t think HABTM is going away… but I believe that
push_with_attributes is.

HMT isn’t appropriate in all cases. There are many times when I want
a relationship between two objects, but the association has usefulness
on its own. I would be unhappy if they got rid of HABTM and
handcuffed me to create a meaningless association models there there
is none needed.

As would I… and I’m also not happy that push_with_attributes has
been deprecated; It’s not a good practice to use
push_with_attributes, but it sure makes it easy to work with a legacy
database where creating a new table just won’t work for you.

Oops, that shoudl read “no usefulness”. Not enough coffee this morning.

…or maybe it is going away. Apparently HABTM is nearing the end of
its life and folks are encouraged to use hmt…

too bad because I think there’s still times when HABTM is useful
(Bosko’s resonse above is a very good one.)

Sorry for the confusion.