Not sure if this is the appropriate place to put this but I asked a question on Stack Overflow and got a bit of interest but now my question seems to have been buried. Just wondering if I could get some help through here?
Unfortunately it didn’t work, when I use create instead of new, the same error gets hung up there as opposed to in the ‘respond_to’ block.
I really don’t get why the shopping_list controller is taking issue with the shopping_list_id. Wouldn’t its id parameter name just be, id instead of shopping_list_id? My items table does have a shopping_list_id column name, would that have anything to do with it?
Here’s a link to the repo if you want to have a look!
I’ve edited the shopping_lists controller to reflect the above changes.
The issue is that Meal model has belongs_to :shopping_list but it doesn’t have column shopping_list_id.
So when you run
ShoppingList.create(meal_ids: ['1'])
Rails tries to create Meal model and link it back to the ShoppingList, but it can’t since there is no such attribute and error tells you that ActiveModel::MissingAttributeError. To fix create a migration e.g.: