small medium large xlarge

10 Oct 2008, 23:10
Giuseppe Caruso (22 posts)

I noticed that on page 122 (beta 1.5) the author wrote: <% for cart_item in @cart.items %> but previously he used <% for item in @cart.items %> Is it an error? Which one should I use?

More, I am using both TextMate then NetBeans to test them. I have to say that NB seems more efficient since auto-completing (which includes your project code too thanks to a parsing it makes on it!) but I noticed that the author uses the following code syntax while calling to an action redirect_to :action => :index while the ide uses redirect_to :action => "index" Is it an error? Rails APIs show, for the examples, the ide syntax.

Thanks you all in advance.

11 Oct 2008, 00:20
Joshua Abbott (2 posts)


cart_item and item are just local variables and can be named however you want. If you wish to use

<% for item in @cart.items %>

everywhere you can, but for the sake of learning it might help to just go with how things are in the book. Either one will work, just make sure if your “for” block is using a local variable named “item” that you’re not calling for cart_item and vice versa.

Also, the :index vs “index” is not an error… either one will work. I personally use :index, but “index” will be fine also.

– Josh

11 Oct 2008, 13:01
Giuseppe Caruso (22 posts)

Thanks a lot Joshua, now it is clearer why! :) May I ask you for another clarification? I didn’t well understand why the author added :layout to the yield method in the store.html.erb file in the layout view files. I am sorry, I am italian mother language, learning another language written in another language… you know… :D ps Just subscribed to your feed. ;)

You must be logged in to comment