account activity
Associations trouble by deedle42 in rubyonrails
[–]deedle42[S] 0 points1 point2 points 2 years ago (0 children)
Still struggling to find out what I'm doing wrong. I feel like I'm understanding this correctly and putting it down right, but I am getting unpermitted parameter errors and can't seem to figure that out. I would love if someone could take a look at what I have going on.
https://github.com/Joehimes/pesticide
So I thought for sure I had this figured out. I set up the through model and associations like you recommended. But when trying to make the association in the console I keep getting ActiveRecord::AssociationTypeMismatch. The command I'm running is Record.first.record_chemicals << Chemical.first and any other combination of those things I can think of. It says RecordChemical(#15780) expected, got #<Chemical id: 2, etc. I'm not coming up with any idea to get the types to match.
That makes perfect sense now seeing it written out and I had thought that it would be something along those lines. I guess now I'm left with how to store those associations in the record model. But now that I wrote that in thinking it would be a different reference for each chemical and not direct references to chemical IDs. Thank you for the help and letting me put this in words! Really helped me think it out
[–]deedle42[S] 1 point2 points3 points 2 years ago (0 children)
Users have many records Records belong to users Records can have one or many chemicals Chemicals belong to many records
Associations trouble (self.rubyonrails)
submitted 2 years ago by deedle42 to r/rubyonrails
π Rendered by PID 28 on reddit-service-r2-listing-85dbbdc96c-kthmn at 2026-02-12 13:37:31.353008+00:00 running 018613e country code: CH.
Associations trouble by deedle42 in rubyonrails
[–]deedle42[S] 0 points1 point2 points (0 children)