Page 1 of 1

Paperclip + ImageMagick help needed

Posted: 2016-02-10T16:29:50-07:00
by alexismarie93
Hey there, I want to be able to upload multiple images at once on my website. I can only upload one image at a time at the moment. Can anybody lead me in the right direction? Here's my code




/app/models/listing.rb



class Listing < ActiveRecord::Base
has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "default.jpg"
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
end



/app/controllers/listings_controller.rb



...
private
# Use callbacks to share common setup or constraints between actions.
def set_listing
@listing = Listing.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def listing_params
params.require(:listing).permit(:name, :description, :price, :image)
end
end



/app/views/listings/_form.html.erb



<%= form_for @listing, :html => { :multipart => true } do |f| %>
...
...
<div class="form-group">
<%= f.file_field :image, class: "form-control" %>
</div>
<div class="form-group">
<%= f.submit class: "btn btn-primary" %>
</div>
<% end %>


/app/views/listings/show.html.erb




<p id="notice"><%= notice %></p>

<%= image_tag @listing.image.url(:medium) %>
...


/app/views/listings/index.html.erb



<h1>Listing listings</h1>

<table>
<thead>
<tr>
<th>Image</th>
<th>Name</th>
...
<tbody>
<% @listings.each do |listing| %>
<tr>
<td><%= image_tag listing.image.url(:medium) %></td>
<td><%= listing.name %></td>
...

Re: Paperclip + ImageMagick help needed

Posted: 2016-02-10T16:50:31-07:00
by fmw42
Hey there, I want to be able to upload multiple images at once on my website. I can only upload one image at a time at the moment. Can anybody lead me in the right direction?
I do not believe that this is an Imagemagick-relevant topic. Perhaps you need to ask on a Paperclip or PHP or other forum. Imagemagick does not do image uploads.