Iam new to rails 4 i want add multiple images.i have a product model and picture model in my app.product has many picture and picture has a image and its a paperclip attachment but i cant access images in my view models/products.rb
class Product < ActiveRecord::Base
belongs_to :user
belongs_to :category
has_many :comments , dependent: :destroy
has_many :pictures, :dependent => :destroy
end
models/picture.rb
class Picture < ActiveRecord::Base
belongs_to :product
accepts_nested_attributes_for :images,:allow_destroy => true
has_attached_file :image,:styles => {
:thumb => ['100x100#', :jpg, :quality => 70],
:preview => ['480x480#', :jpg, :quality => 70],
:large => ['600>', :jpg, :quality => 70],
:retina => ['1200>', :jpg, :quality => 30]
},
:path => ":rails_root/public/images/:id/:filename",
:url => "/images/:id/:filename"
do_not_validate_attachment_file_type :image
end
View page
<div class="row">
<% @products.each do |product| %>
<div class="col-sm-3 col-lg-3 col-md-3">
<div class="thumbnail">
<%= product.image.url(:thumb) %>
<div class="caption">
<h4 class="pull-right">Rs.<%= product.price %> </h4>
<h4><%= link_to 'Show', product %>
</h4>
<p><strong>Name:</strong>  <%= product.name %></span></p>
<% if !product.description.blank? %>
<p><strong>Description:</strong> <%= product.description %></p>
<% end %>
<% if !product.reason.blank? %>
<p><strong>Reason:</strong><%= product.reason %></p>
<% end %>
</div>
</div>
</div>
<% end %>
</div>