Sunday 15 May 2011

views - Agile Web Developement with Rails 3.2 Listing Products page includes extra information -


Hey everybody, I'm studying with Rails on Rails 3.2, along with the Excel Web Development, and I have come to a problem that I do not know how to fix app / view / products / index.html.erb
  & lt; H1 & gt; Listing Products & lt; / H1> Has created a product view with the following code. & Lt; Table & gt; & Lt;% = @ products.each do | Products | & Gt%; & Lt; Tr class = "& lt;% = cycle ('list_line_odd', 'list_line_even')%>" & Gt; & Lt; TD & gt; & Lt;% = image_tag (product.image_url, category: 'list_image')%> & Lt; / TD & gt; & Lt; Td class = "list_description" & gt; & Lt; DL & gt; & Lt; Dt & gt; & Lt;% = product.title% & gt; & Lt; / Dt & gt; & Lt; Dd & gt; & Lt;% = truncate (strip_tags (product description), length: 80)% & gt; & Lt; / Dd> & Lt; / DL & gt; & Lt; / TD & gt; & Lt; Td class = "list_actions" & gt; & Lt;% = link_to 'Show', Product% & gt; & Lt; Br / & gt; & Lt;% = link_to 'edit', edit_product_path (product)%> & Lt; Br / & gt; & Lt;% = link_to 'deleted', product, method :: delete, data: {confirm: 'are you sure?' }% & Gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt;% end% & gt; & Lt; / Table & gt; & Lt; Br / & gt; & Lt;% = link_to 'New Product', new_product_path% & gt;   

This page displays everything properly, but forces additional exclusions at the top of the page:

[# \ nCoffee Script JavaScript True ... ", image_url:" cs.jpg ", value: #, created_t:" 2013-06-22 23:34:33 ", updated_t:" 2013-06-22 23:34:33 "& gt; ;; # \ N Ruby is fastest and the fastest is ... ", image_url:" ruby.jpg ", value: #, created_t:" 2013-06-22 23:34:33 ", updated_t: "2013-06-22 23:34:33" & gt;, # \ n test preserves rail one is ... ", image_url:" rtp.jpg ", value: #, created_at:" 2013-06-22 23: 34: 33 ", updated_at:" 2013-06-22 23:34:33 "& gt;]

I am not sure whether this is the rail output in the standard development environment. Is there anything wrong in my code? I know that this is probably a simple question, so any help is appreciated. It is expected that I have included enough information in the details so that other people with the same problem can easily get the solution.

The problem is in this line:

  & lt;% = @ products.each do | Product |% & gt;   

You do not need = because you are not just trying to penetrate the products in the resultant HTML generate an output from this statement = With you are basically receiving ruby ​​dump of @Products table (you have asked Ruby to take the output of the @ products.each clause and inject it into < Code> & lt; Table & gt; and your first & lt; tr ... & gt; between HTML) Instead, its Ryog to:

  & lt;% @ products.each do | Products | & Gt%;    

No comments:

Post a Comment