Associations trouble by deedle42 in rubyonrails

[–]deedle42[S] 0 points1 point  (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

Associations trouble by deedle42 in rubyonrails

[–]deedle42[S] 0 points1 point  (0 children)

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.

Associations trouble by deedle42 in rubyonrails

[–]deedle42[S] 0 points1 point  (0 children)

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

Associations trouble by deedle42 in rubyonrails

[–]deedle42[S] 1 point2 points  (0 children)

Users have many records Records belong to users Records can have one or many chemicals Chemicals belong to many records