Skip to content

Instantly share code, notes, and snippets.

@ysinc88
Created February 26, 2015 20:23
Show Gist options
  • Save ysinc88/45d90cffdd5b5947674b to your computer and use it in GitHub Desktop.
Save ysinc88/45d90cffdd5b5947674b to your computer and use it in GitHub Desktop.
Product images per product
class PagesController < ApplicationController
def store
@products = Product.all
render 'store'
end
end
class Product < ActiveRecord::Base
belongs_to :product_category
has_many :product_images
end
class ProductImage < ActiveRecord::Base
belongs_to :product
end
<% @products.each do |p| %>
<div class="col-md-6 product-front">
<h3>
<%= link_to(p.name, product_path(p)) %>
</h3>
<div class="row product-details">
<ul>
<li class="col-md-12">Dimensions:
<span class="pull-right">
<%= p.dimensions %>
</span></li>
<li class="col-md-12"># of LEDs:
<span class="pull-right">
<%= p.led_count %>
</span></li>
<li class="col-md-12">Wavelengths:
<span class="pull-right">
<%= p.wavelengths%>
</span></li>
<li class="col-md-12">Effective lighting area:
<span class="pull-right">
<%= p.lighting_area%>
</span></li>
</ul>
</div>
<div class="product-gallery container">
<div class="col-md-12 main-image">
<%= image_tag("store/01-DSC_0216.JPG") %>
<!-- To be populated with product feature image-->
</div>
<div class="mini-images col-md-12 col-xs-12">
<% p.product_images.each do |img| %>
<div class="col-md-4 col-xs-4 mini-image">
<%= link_to(image_tag(img.src), "#") %>
</div>
<% end %>
</div>
</div>
<div class="buttons col-md-12">
<button class="col-md-6" type="button">Details</button>
<button class="col-md-6" type="button">Buy</button></div>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment