mercredi 10 février 2016

How to add multiple images using carrierwave

i created form, but on click ,choose image option is not appending to add multiple images. Please give me a solution for this

my property form.html.erb

<%= simple_nested_form_for ([:generic_users, @property]) do |f| %>
<%= f.input :image, required: true %>
    <p><%= image_tag @property.image_url(:thumbnail) if @property.image? %></p>
    <%= f.hidden_field :image_cache %>
    <%= f.simple_fields_for :property_images do |i| %>
      <%= i.input :image %>
      <p><%= image_tag i.object.image_url(:thumbnail) if i.object.image? %></p>
      <%= i.hidden_field :image_cache %>
      <%= i.link_to_remove 'Remove',method: :delete, class: 'btn btn-danger'%>
    <% end %>
   </div>
   </div>
   <hr>
   <%= f.link_to_add 'Add Image', :property_images, class: 'btn btn-primary', data: {target: '.additional-images'} %>
  <hr>
<% end %>
this is my propertyImage model

class PropertyImage < ActiveRecord::Base
  belongs_to :property
  validates_presence_of :image
  mount_uploader :image, ImageUploader
end
my property.rb

class Property < ActiveRecord::Base
has_many :property_images, dependent: :destroy
accepts_nested_attributes_for :property_images, allow_destroy: true
end

This is how i am getting page , on clicking Add Image , multiple option for choose image is not appearing. Please give me a solution

enter image description here

Aucun commentaire:

Enregistrer un commentaire