Forum: Ruby on Rails Is HABTM Dying?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Steve R. (Guest)
on 2006-06-05 07:27
(Received via mailing list)
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.
Bosko M. (Guest)
on 2006-06-05 07:46
(Received via mailing list)
On 6/4/06, s.ross <removed_email_address@domain.invalid> 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."
Joe (Guest)
on 2006-06-05 09:14
Check this out:
http://blog.hasmanythrough.com/articles/2006/04/20...

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

Joe
Brian H. (Guest)
on 2006-06-05 16:24
(Received via mailing list)
I don't think HABTM is going away... but I believe that
push_with_attributes is.
Brian H. (Guest)
on 2006-06-05 16:34
(Received via mailing list)
...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.
Kenneth L. (Guest)
on 2006-06-05 19:59
(Received via mailing list)
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.
Brian H. (Guest)
on 2006-06-05 20:06
(Received via mailing list)
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.
Kenneth L. (Guest)
on 2006-06-05 20:41
(Received via mailing list)
Oops, that shoudl read "no usefulness".  Not enough coffee this morning.
This topic is locked and can not be replied to.