Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Controller
- @men = Category.find(1)
- @unisex = Category.find(2)
- @women = Category.find(3)
- # View
- <div class="column column1">
- <h3>MEN</h3>
- <%= render :partial => 'product_list', :locals => { :products => @men.products } %>
- </div>
- <div class="column column2">
- <h3>UNISEX</h3>
- <%= render :partial => 'product_list', :locals => { :products => @unisex.products } %>
- </div>
- <div class="column column3">
- <h3>WOMEN</h3>
- <%= render :partial => 'product_list', :locals => { :products => @women.products } %>
- </div>
- # Partial
- <% products.each do |product| %>
- <div class="product" style="clear:both;">
- <p><b><%= product.name %></b></p>
- <img src="<%= url_for_image product %>" width="175" height="175" align="left" hspace="0" vspace="0" style="margin-left: 5px;" alt="" />
- <div style="text-align: left;">
- <% product.features.find(:all, :conditions => "name = 'color'").each do |feature|
- feature.feature_values.each do |fv| %>
- <p><%= link_to fv.name, :controller => 'product', :action => 'view', :id => product, :color => fv.id %></p>
- <%
- end
- end
- %>
- </div>
- </div>
- <% end %>
- # Helper
- module ApplicationHelper
- def url_for_image(object)
- current_class = object.class.class_name
- puts 'test'
- puts current_class
- puts 'test'
- directory = '/images' + current_class + '/image'
- unless object.image.nil?
- (directory + object.id + '/' + File.basename(object.image))
- else
- 'noimage.gif'
- end
- end
- end
Add Comment
Please, Sign In to add comment