Hello. Congratulations for this great book. I am learning a lot.
However, I have a doubt. I am on page 144 (b6), creating the Ajax cart. The code that is confusing me is the following:
<%= render @cart %>
I understand the render command. According to the guide, the argument can be a string or a symbol (like render :new). However, we need to setup this @cart variable, which doesn’t exist.
@cart = current_cart
This last line, according to my understanding, returns a model instance (Cart.create or Cart.find in Application#current_cart). The argument ‘@cart’ is neither a symbol nor a string. How does ‘render @a_model_variable’ behave?
I am guessing that since @cart is Cart.create, the render command will render ‘create’ action from the ‘Cart’ controller. That makes sense, but what about the moment it returns Cart.find?
Thanks in advance for the response.