# Can't get data from products into @order

**URL:** <https://www.ruby-forum.com/t/cant-get-data-from-products-into-order/51000>\
**Category:** Rails\
**Created:** [December 23, 2005, 7:27pm UTC](https://www.ruby-forum.com/t/cant-get-data-from-products-into-order/51000 "2005-12-23T19:27:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie\_bowman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b5e925/32.png) [@charlie\_bowman](https://www.ruby-forum.com/u/charlie_bowman)\
**Post date:** [December 23, 2005, 7:27pm UTC](https://www.ruby-forum.com/t/cant-get-data-from-products-into-order/51000/1 "2005-12-23T19:27:45Z")

</div>

I went throught the “agile web developemnt with rails” and Now I’m  
trying to ‘enhance’ the code with some extra options. When I go to  
admin/shipping I want to include some data from the products table in  
with the order info listed. I can’t seem to get this to work. in my  
partial form I’m trying to add this:

 \<%= order\_line.image\_url %\>

I’m recieving this error  
undefined method `image\_url’ for #Order:0xb77ee194

I call the partial with:

\<%= render(:partial =\> "order\_line", :collection =\> @pending\_orders) %\>

Here is how I get @pending\_orders  
@pending\_orders = Order.pending\_shipping

and finally my order class  
class Order \< ActiveRecord::Base

has\_many :line\_items

# function to retrieve all orders that haven’t been marked as shipped

yet.

# this allows us to see what orders have been made

def self.pending\_shipping  
find(:all, :conditions =\> “shipped\_at is null”)  
end

end

What do I need to do to get some product data into my shipping view?

---

<div class="post-metadata">

**Author:** ![charlie\_bowman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b5e925/32.png) [@charlie\_bowman](https://www.ruby-forum.com/u/charlie_bowman)\
**Post date:** [December 23, 2005, 9:21pm UTC](https://www.ruby-forum.com/t/cant-get-data-from-products-into-order/51000/2 "2005-12-23T21:21:58Z")

</div>

Charlie,

Could be that image\_url is not known in the model for order\_line. I  
think it  
should be something like “order\_line.image\_url = product.image\_url”

Something similar is done in the books example webshop in  
models/line\_item.rb  
with: “item.unit\_price = product.price”

Hope it helps.

Gerard.

On Friday 23 December 2005 19:27, charlie bowman tried to type something  
like:

> I’m recieving this error  
> and finally my order class
> 
> end
> 
> What do I need to do to get some product data into my shipping view?

–  
“Who cares if it doesn’t do anything? It was made with our new  
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;  
~  
:wq!

---

<div class="post-metadata">

**Author:** ![charlie\_bowman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b5e925/32.png) [@charlie\_bowman](https://www.ruby-forum.com/u/charlie_bowman)\
**Post date:** [December 23, 2005, 10:00pm UTC](https://www.ruby-forum.com/t/cant-get-data-from-products-into-order/51000/3 "2005-12-23T22:00:49Z")

</div>

order\_line isn’t acutally a model. It is the name of the partial form.  
it holds the value @pending\_orders. I need to get data from the product  
table into @pending\_orders.

Gerard wrote:

> Charlie,
> 
> Could be that image\_url is not known in the model for order\_line. I  
> think it  
> should be something like “order\_line.image\_url = product.image\_url”
> 
> Something similar is done in the books example webshop in  
> models/line\_item.rb  
> with: “item.unit\_price = product.price”
> 
> Hope it helps.
> 
> Gerard.

---

<div class="post-metadata">

**Author:** ![charlie\_bowman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b5e925/32.png) [@charlie\_bowman](https://www.ruby-forum.com/u/charlie_bowman)\
**Post date:** [December 23, 2005, 10:58pm UTC](https://www.ruby-forum.com/t/cant-get-data-from-products-into-order/51000/4 "2005-12-23T22:58:16Z")

</div>

Charlie,

Mind you I’m a newbie so this discussion might end up beyond the scope  
of my  
knowledge. Nevertheless, digging back in the book, the data needs to be  
available in the controller (getting it from the model) when you want to  
display it in the view. Product info is available (in the admin  
controller)  
when generating the “orders pending” list. Have you simply tried  
“product.image\_url”.

Regards,

Gerard.

On Friday 23 December 2005 22:00, charlie bowman tried to type something  
like:

> > Something similar is done in the books example webshop in  
> > models/line\_item.rb  
> > with: “item.unit\_price = product.price”
> > 
> > Hope it helps.
> > 
> > Gerard.

–  
“Who cares if it doesn’t do anything? It was made with our new  
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;  
~  
:wq!

---

<div class="post-metadata">

**Author:** ![charlie\_bowman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b5e925/32.png) [@charlie\_bowman](https://www.ruby-forum.com/u/charlie_bowman)\
**Post date:** [December 23, 2005, 10:01pm UTC](https://www.ruby-forum.com/t/cant-get-data-from-products-into-order/51000/5 "2005-12-23T22:01:07Z")

</div>

order\_line isn’t actually a model. it is the name of  
the partial form. Within that form order\_line holds  
the value of @pending\_orders. I need product info in  
pending orders.

— Gerard [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> options. When I go to
> 
> > I’m recieving this error  
> > @pending\_orders = Order.pending\_shipping  
> > made  
> > –

* * *

Yahoo! for Good - Make a difference this year.  
[http://brand.yahoo.com/cybergivingweek2005/](http://brand.yahoo.com/cybergivingweek2005/)

---

<div class="post-metadata">

**Author:** ![charlie\_bowman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b5e925/32.png) [@charlie\_bowman](https://www.ruby-forum.com/u/charlie_bowman)\
**Post date:** [December 23, 2005, 11:16pm UTC](https://www.ruby-forum.com/t/cant-get-data-from-products-into-order/51000/6 "2005-12-23T23:16:19Z")

</div>

Charlie,

When adding a line to “views/admin/\_order\_line.rhtml”  
(The one with \<\<\< behind it)

 \<% order\_line.line\_items.each do |li| %\> 
\<%= li.quantity %\>\<%= li.product.title %\>\<%= li.product.image\_url %\> \<\<\<\< 
 \<% end %\> 

It shows /images/picture.jpg in the html output. So when encapsulated in  
an  
 ![]() tag you should see a picture.

Is that’s what your looking for?

Regards,

Gerard.

On Friday 23 December 2005 22:00, charlie bowman tried to type something  
like:

> > Something similar is done in the books example webshop in  
> > models/line\_item.rb  
> > with: “item.unit\_price = product.price”
> > 
> > Hope it helps.
> > 
> > Gerard.

–  
“Who cares if it doesn’t do anything? It was made with our new  
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;  
~  
:wq!
