Hoping you can help with me an issue I'm currently having.
I've set up Paperclip to help me with image uploading and after following instructions and checking various guides, I believe it should be working, but I am running into an issue where it's simply not saving the image and displaying the following error. Can anyone point a learner in the right direction?
I've used imagemagick to convert via the command line without any issues.
UPDATE: I've just looked through my files again and found that I've added this as it asked in the documentation. Do I need to amend the :command_path
UPDATE 2: I have fixed the issue now and my resolution is the answer section belo.
Paperclip.options[:command_path] = "/usr/local/bin/"
.
There was an error processing the thumbnail for f87ef1d19d0a3693810436f1278205e020150803-666-1avrc9e
The extracted source is as follows:
def create
admin = Admin.new(admin_params)
if admin.save
redirect_to '/administration'
Parameters
{"utf8"=>"✓",
"authenticity_token"=>"lZ9kDGwvbTUTElcOkKPrgpmiX9HlIfVpAXyRROk/jcRdoGJX9/unlBx6SuazNa9BXw0UIJhbmJiSUVin4DrsBg==",
"admin"=>{"name"=>"fffsfdsa",
"email"=>"dfsdfsfadsafsd@gmail.com",
"user_name"=>"hjdfkhasdjhasjfdkh",
"password"=>"[FILTERED]",
"password_confirmation"=>"[FILTERED]",
"avatar"=>#<ActionDispatch::Http::UploadedFile:0x007f9082386cf0 @tempfile=#<Tempfile:/var/folders/t6/jrprg2rd57zch5mkt5cg_5cr0000gn/T/RackMultipart20150803-666-1crp2va.jpg>,
@original_filename="image_name.jpg",
@content_type="image/jpeg",
@headers="Content-Disposition: form-data; name=\"admin[avatar]\"; filename=\"image_name.jpg\"\r\nContent-Type: image/jpeg\r\n">},
"commit"=>"Submit"}
Model (admin.rb)
class Admin < ActiveRecord::Base
has_secure_password
has_attached_file :avatar, :styles => {
:medium => "300x300>",
:thumb => "50x50#>"},
:default_url => "/images/:style/missing.png"
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
end
Admin Controller
class AdminController < ApplicationController
def new
end
def create
admin = Admin.new(admin_params)
if admin.save
redirect_to '/administration'
flash[:success] = "Admin account created successfully"
else
flash[:error] = "Unable to create account"
render 'administration/new_ai_admin'
end
end
private
def admin_params
params.require(:admin).permit(:name, :email, :user_name, :password, :password_confirmation, :avatar)
end
end
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire