MaMpf-HD / mampf

MaMpf (Mathematical Media Platform) — an E-Learning platform for mathematics featuring a media player & editor. Developed & deployed at Heidelberg University.
https://mampf.mathi.uni-heidelberg.de/
MIT License
27 stars 10 forks source link

Undefined method 'intersect?' #583

Closed fosterfarrell9 closed 8 months ago

fosterfarrell9 commented 8 months ago

Since rolling out #579, we are seeing the follwing error in production:

undefined method `intersect?' for #<ActiveRecord::Associations::CollectionProxy [#<Tag id: 636, created_at: "2019-01-05 17:21:40.169479000 +0100", updated_at: "2022-02-25 14:17:38.015382000 +0100", realizations: []>, #<Tag id: 656, created_at: "2019-01-28 18:53:41.680154000 +0100", updated_at: "2021-11-18 09:26:39.281654000 +0100", realizations: []>]> Did you mean? insert 

The reason is that in media_controller.rb, we have in line 639

m.teachable_type == "Course" && !m.tags.intersect?(lecture_tags)

which replaced

m.teachable_type == 'Course' && (m.tags & lecture_tags).blank?

but m.tags is an ActiveRecord collection, not an an array, so there is no intersect? method here (where as in the code before, an automatic conversion seems to have happened).

I think an obvious solution would be to write m.tags.to_a.intersect?.

Splines commented 8 months ago

Repro in localhost:

Log in as student 2, access LA2 lecture and click on "Worked Examples"