Guest User

Untitled

a guest
Feb 21st, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1.  
  2. # Controller
  3. @men = Category.find(1)
  4. @unisex = Category.find(2)
  5. @women = Category.find(3)
  6.  
  7. # View
  8. <div class="column column1">
  9. <h3>MEN</h3>
  10. <%= render :partial => 'product_list', :locals => { :products => @men.products } %>
  11. </div>
  12. <div class="column column2">
  13. <h3>UNISEX</h3>
  14. <%= render :partial => 'product_list', :locals => { :products => @unisex.products } %>
  15. </div>
  16. <div class="column column3">
  17. <h3>WOMEN</h3>
  18. <%= render :partial => 'product_list', :locals => { :products => @women.products } %>
  19. </div>
  20.  
  21. # Partial
  22. <% products.each do |product| %>
  23. <div class="product" style="clear:both;">
  24. <p><b><%= product.name %></b></p>
  25. <img src="<%= url_for_image product %>" width="175" height="175" align="left" hspace="0" vspace="0" style="margin-left: 5px;" alt="" />
  26. <div style="text-align: left;">
  27. <% product.features.find(:all, :conditions => "name = 'color'").each do |feature|
  28. feature.feature_values.each do |fv| %>
  29. <p><%= link_to fv.name, :controller => 'product', :action => 'view', :id => product, :color => fv.id %></p>
  30. <%
  31. end
  32. end
  33. %>
  34. </div>
  35. </div>
  36. <% end %>
  37.  
  38. # Helper
  39. module ApplicationHelper
  40. def url_for_image(object)
  41. current_class = object.class.class_name
  42. puts 'test'
  43. puts current_class
  44. puts 'test'
  45. directory = '/images' + current_class + '/image'
  46.  
  47. unless object.image.nil?
  48. (directory + object.id + '/' + File.basename(object.image))
  49. else
  50. 'noimage.gif'
  51. end
  52. end
  53. end
Add Comment
Please, Sign In to add comment