I am using paperclip in my rails app
my form is
<%= form_for @portfolio_photo, :url => portfolio_photo_uplaod_individual_profile_path(:profile_id => current_individual.profile.id), :method => :POST, :html => { :multipart => true } do |f| %>
<%= f.hidden_field :profile_id, :value => current_individual.profile.id %>
<%= file_field_tag :portfolio_photo, multiple: true %>
<%= f.submit "submit" %>
<% end %>
and controller action is
def portfolio_photo_uplaod
@portfolio_photo = IndividualPhoto.create(portfolio_photo_params)
if @portfolio_photo.save
redirect_to individual_profile_path(current_individual)
end
end
and the strong parameters are
def portfolio_photo_params
params.permit(:portfolio_photo, :profile_id)
end
individual_photo.rb
class IndividualPhoto < ActiveRecord::Base
belongs_to :profile
has_attached_file :portfolio_photo, :styles => { :medium => "300x300>" }
validates_attachment_content_type :portfolio_photo, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
end
profile.rb
has_many :individual_photos
i am able to save when i upload a single image but i am not able to save multiple images instead only one image is saving in the database when i upload multiple images Please help !!