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: <td class="olnamebox"> <%= order_line.image_url %> </td> I''m recieving this error undefined method `image_url'' for #<Order:0xb77ee194> I call the partial with: <table cellpadding="5" cellspacing="0"> <%= render(:partial => "order_line", :collection => @pending_orders) %> </table> 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? -- Posted via http://www.ruby-forum.com/.
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 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: > > <td class="olnamebox"> > <%= order_line.image_url %> > </td> > > I''m recieving this error > undefined method `image_url'' for #<Order:0xb77ee194> > > I call the partial with: > <table cellpadding="5" cellspacing="0"> > <%= render(:partial => "order_line", :collection => @pending_orders) %> > </table> > > 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?-- "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 <mailing-cTiHyVPm3bxmR6Xm/wNWPw@public.gmane.org> 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. > > > On Friday 23 December 2005 19:27, charlie bowman > tried to type something like: > > 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: > > > > <td class="olnamebox"> > > <%= order_line.image_url %> > > </td> > > > > I''m recieving this error > > undefined method `image_url'' for > #<Order:0xb77ee194> > > > > I call the partial with: > > <table cellpadding="5" cellspacing="0"> > > <%= render(:partial => "order_line", :collection > => @pending_orders) %> > > </table> > > > > 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? > > -- > "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! > > > >__________________________________ Yahoo! for Good - Make a difference this year. http://brand.yahoo.com/cybergivingweek2005/
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. >-- Posted via http://www.ruby-forum.com/.
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:> 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.-- "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!
Charlie, When adding a line to "views/admin/_order_line.rhtml" (The one with <<< behind it) <td class="olitembox"> <% order_line.line_items.each do |li| %> <div class="olitem"> <span class="olitemqty"><%= li.quantity %></span> <span class="olitemtitle"><%= li.product.title %></span> <span class="olitemtitle"><%= li.product.image_url %></span> <<<< </div> <% end %> </td> It shows /images/picture.jpg in the html output. So when encapsulated in an <img> 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:> 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.-- "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!