Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HABTM broken promise #12582

Closed
lukaszx0 opened this issue Oct 18, 2013 · 8 comments
Closed

HABTM broken promise #12582

lukaszx0 opened this issue Oct 18, 2013 · 8 comments
Assignees
Milestone

Comments

@lukaszx0
Copy link
Member

Quoting changelog (https://github.com/rails/rails/blob/master/activerecord/CHANGELOG.md) :

has_and_belongs_to_many is now transparently implemented in terms of has_many :through. Behaviour should remain the same, if not, it is a bug.

It looks like it's not. I wanted to fix issue in AMS yesterday and it turned out it was broken only on edge rails and problem was with HABTM. Here's AMS PR: rails-api/active_model_serializers#404

I'll post proper failing test case for rails & will try to fix this issue later today.

/cc @tenderlove

@lukaszx0
Copy link
Member Author

Forgot to mention. It's broken on master.

@tenderlove
Copy link
Member

Any progress on a test case?

@rafaelfranca
Copy link
Member

@spastorino @strzalek we will need a test case on the Rails code base. 😉

@lukaszx0
Copy link
Member Author

Yes of course, I can and I will provide that.

@tenderlove sorry for no update on this. Few hours after posting this issue my macbook air died. I'll have it back in 4-5 days with replaced ssd and then I will try to attack this issue if anybody won't fix it before.

@ghost ghost assigned lukaszx0 Nov 22, 2013
@lukaszx0
Copy link
Member Author

@tenderlove thanks a lot! 🤘

maurogeorge added a commit to maurogeorge/shoulda-matchers that referenced this issue Jan 19, 2014
maurogeorge added a commit to maurogeorge/shoulda-matchers that referenced this issue Jan 24, 2014
maurogeorge added a commit to maurogeorge/shoulda-matchers that referenced this issue Feb 9, 2014
maurogeorge added a commit to maurogeorge/shoulda-matchers that referenced this issue Feb 15, 2014
@tanelj
Copy link

tanelj commented Mar 12, 2014

Hi!

It seems that there are still some issues with HABTM.

In Rail 4.1.0.rc1 (and in current 4.1 master) HABTM does not respect validate: false:

has_and_belongs_to_many :languages, validate: false

Currently validation is always called for associated objects.

For example this code is calling validation (on: :create) for language object even when validate: false:

event = Event.new
event.languages << Language.first
event.valid?

Here is minitest about the issue: https://gist.github.com/tanelj/9517608

It works fine in Rails 4.0.3.

@tenderlove
Copy link
Member

@tanelj nice, thanks for the test case!

@carlosantoniodasilva
Copy link
Member

@tanelj this has been fixed on master bae7f1d and backported to 4.1, should be good to go. Thanks for the test case, was very helpful! ❤️

edbo added a commit to bitgaming/octopus that referenced this issue Mar 26, 2014
Rails 4.1.0 no longer has that class. It has been replaced with HasManyThroughAssociation rails/rails#12582
maurogeorge added a commit to maurogeorge/shoulda-matchers that referenced this issue Apr 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants