[Rails] "Undefined method" problem in "Agile Web Development With Rails"

David Mitchell monch1962 at gmail.com
Sun Mar 5 20:43:27 GMT 2006


For some reason your object "item" has the value 2395.0, and is a
floating point object.  Without having the Agile book at my
fingertips, from memory it's supposed to have a price attribute with
that value.

At a guess, you could be setting @items to an individual item, rather
than a collection of items.  That would be consistent with the error
you're seeing.

Have a look at your controller code where you set @items to something;
the problem's probably going to be right around there.

HTH

Dave M.

On 06/03/06, Emil Gustafsson <emil at classicbildelar.com> wrote:
> Hi,
>
> I'm reading the "Agile Web Development With Rails" book. So long, everything
> has worked fine, but now I got this annoying error message that I just can't
> understand. The error appears for me around page 87, chapter 8.
>
>
>
> NoMethodError in Store#display_cart
>
> Showing app/views/store/display_cart.rhtml where line #28
> raised:
> undefined method `product' for 2395.0:Float
>
>
>
>
> Extracted source (around line #28):
> 25: </tr>
> 26: <%
> 27: for item in @items
> 28: product = item.product
> 29: -%>
> 30: <tr>
> 31: <td><%= h(product.title) %></td>
>
>
> I'm sure my source code is correct.
>
> //Emil
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>


More information about the Rails mailing list