Hi All. First to start, please bare with me as I'm really confused on
all this and have been stuck for about a day now, so I'm not sure if I
will even be asking the right questions or not, but here goes.
I'm trying to create a Menu object and then assign a group of Day
objects to it. This part is working fine. Next I want to go and update
this Menu and all of the Day objects associated with it. I've watched
the railscast on complex forms, so it kind of makes sense to me, but
there are a few differences here. Each Day object has an associated Meal
object. The meals are already created, so all I'm trying to do is assign
a single Meal to a Day, then update the Menu and all of the days at the
same time.
Here is the code I have. (I have trimmed down a lot of what isn't needed
for this, but I can provide more code if it will help).
The actual issue that I'm having is that when I update the menu, then
click edit again to edit a second time, I now have extra days. Where I
first started with 20, I will have an extra "x" amount where "x" is the
number of days that I updated. So if I update 6 days, then now I will
have 26 days total, but 6 of those days won't be saved correctly because
they will be missing some info.
small correction in the controller code, I know the
@menu.update_attributes!(params[:menu]) was commented out. That was from
some testing, I just forgot to uncomment before posting.
Ok, I'm thinking it might have something to do with the checkboxes. If I
place a number into the text_field, and update, then everything seems
ok. If I check a box, then that's when it gets all weird.