Hello Ryan, A happy new year to you! I have gone through the screencasts a few times and now am working through the code starting with Episode 1. Here is what I have found thus far:
You have omissions in the code. I am not sure if deliberate or otherwise. Specifically pizza.rb model file has the following lines missing:
has_many :pizza_toppings has_many :toppings, :through => :pizza_toppings
Also, the following line has the topping_ids missing in the same file (pizza.rb model file):
attr_accessible :name, :crispy, :crust_type_id, :topping_ids <– this is missing.
No big deal. You do talk about it in the screencast though.
Also, I really appreciate your focusing on the fundamentals. Things like how to read the API docs and find the information is very useful.
Now the question: you talk about using the collection_singular_ids=ids method which reads “Replace the collection with the objects identified by the primary keys in ids” I am trying to understand it and cannot. Are you referring to the “:topping_ids” that I point to above? The form code specific to this as I see it is below:
<% for topping in Topping.all %> <p> <%= check_box_tag ‘pizza[topping_ids]’, topping.id, @pizza.toppings.include?(topping) %> <%=h topping.name %> </p> <% end %> <%= hidden_field_tag ‘pizza[topping_ids]’, ‘’ %>
I am mentally unable to make the connection between the code shown and the collection_singular_ids=ids method. A few sentences of explanation would be great.