Ruby on Rails - Using callback to multiply two objects in separate tables when new entry is created
问题 I have 3 tables, Goals, Activities and Goal_Activities. Goal has a set value for xp and Activity takes an input from the user. Using the on_create method in Activity, I'd like to multiply the user input with the goal xp and store that in the Goal Activities table so I can keep a record of each update and eventually add them all together to create a total goal xp in the Goal table. I've found a couple of questions on SO, here and here, that cover similar topics but I'm finding it hard to get