# RoR Hell. Agile Web Development book example problems

**URL:** <https://www.ruby-forum.com/t/ror-hell-agile-web-development-book-example-problems/73250>\
**Category:** Rails\
**Created:** [October 23, 2006, 8:22am UTC](https://www.ruby-forum.com/t/ror-hell-agile-web-development-book-example-problems/73250 "2006-10-23T08:22:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zach\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a9a28c/32.png) [@Zach\_I](https://www.ruby-forum.com/u/Zach_I)\
**Post date:** [October 23, 2006, 8:22am UTC](https://www.ruby-forum.com/t/ror-hell-agile-web-development-book-example-problems/73250/1 "2006-10-23T08:22:32Z")

</div>

[http://pastie.caboo.se/19069](http://pastie.caboo.se/19069)

I’ve tried this with putting the app/ of the example over mine and tried  
running the whole thing but still no luck.

Im using Locomotive 2.0.8

Please someone help 🙂

---

<div class="post-metadata">

**Author:** ![Zach\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a9a28c/32.png) [@Zach\_I](https://www.ruby-forum.com/u/Zach_I)\
**Post date:** [October 23, 2006, 8:28am UTC](https://www.ruby-forum.com/t/ror-hell-agile-web-development-book-example-problems/73250/2 "2006-10-23T08:28:51Z")

</div>

It seems that @cart.items is returning floats, not items. Maybe check  
out your cart model.

On Oct 23, 12:22 am, Zach I. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Zach\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a9a28c/32.png) [@Zach\_I](https://www.ruby-forum.com/u/Zach_I)\
**Post date:** [October 23, 2006, 8:54am UTC](https://www.ruby-forum.com/t/ror-hell-agile-web-development-book-example-problems/73250/3 "2006-10-23T08:54:22Z")

</div>

Nothing jumps out at me as being wrong?

[http://pastie.caboo.se/19088](http://pastie.caboo.se/19088)

I know it doesn’t mind @item but when I pass it as a set of items, it  
doesn’t like it.

---

<div class="post-metadata">

**Author:** ![Zach\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a9a28c/32.png) [@Zach\_I](https://www.ruby-forum.com/u/Zach_I)\
**Post date:** [October 23, 2006, 9:21am UTC](https://www.ruby-forum.com/t/ror-hell-agile-web-development-book-example-problems/73250/4 "2006-10-23T09:21:01Z")

</div>

Line 9 of line\_item.rb

In Ruby, a function returns the value of the last line. The for\_product  
function is returning the product.price, instead of the item.

You want to add a line to return the item itself:

def self.for\_product(product)  
item = self.new  
item.quantity = 1  
item.product = product  
item.unit\_price = product.price  
item  
end

---

<div class="post-metadata">

**Author:** ![Zach\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a9a28c/32.png) [@Zach\_I](https://www.ruby-forum.com/u/Zach_I)\
**Post date:** [October 23, 2006, 9:41pm UTC](https://www.ruby-forum.com/t/ror-hell-agile-web-development-book-example-problems/73250/5 "2006-10-23T21:41:14Z")

</div>

Brilliant. That’s defiantely helped. I’m now getting…  
undefined local variable or method `product’

So how should I pass the product across from the model to my controller?

---

<div class="post-metadata">

**Author:** ![Zach\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a9a28c/32.png) [@Zach\_I](https://www.ruby-forum.com/u/Zach_I)\
**Post date:** [October 23, 2006, 10:25pm UTC](https://www.ruby-forum.com/t/ror-hell-agile-web-development-book-example-problems/73250/6 "2006-10-23T22:25:59Z")

</div>

Getting error at:  
6: product.item\_product
