Can't get data from products into @order

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?

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!

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.

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!

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 [email protected] 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/

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!