paperclip

Troubles setting up Paperclip + AWS S3 for image storing in our Rails3/Heroku App

拜拜、爱过 提交于 2019-12-04 09:57:46
We have already built a rails app that has several users and an image for each of them. Doing all of the dev work on our localhost, we have working seeds for users & photos...but now that we are trying to use S3 for the image storage, we are running into errors during...always during the "seed" step of the migrations, when doing this: rake db:migrate:reset Apologies for the question, but we have have been banging our heads on this for 11 hours, having gone through every related Stack question on the subject. A lot of similar posts had a NoSuchBucket error and other types of issues, but we none

Paperclip, multiple attachments and validation

故事扮演 提交于 2019-12-04 09:39:52
问题 Does anybody have a Rails 3 example of multiple attachments working with validation on a multipart form? I've been trying to get this working forever (and have found every blog post and message I could, but none cover this situation, and the docs don't help at all). The first problem is that most examples use 'new_record?' in the view template, but this always returns true in a new/create sequence when validation fails because no model instances have been saved (so no 'id' value). So if you

Paperclip: upload from url with extension

时光毁灭记忆、已成空白 提交于 2019-12-04 09:29:35
问题 I would like to upload pictures from URLs by paperclip on S3 storage. I work with : Ruby 1.9.3 Rails 3.2.6 paperclip 3.1.3 aws-sdk 1.3.9 I have my Picture Model: class Asset has_attached_file :asset, :styles => {:thumb => "60x60>"}, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml", :path => "/pictures/:id/:style.:extension" validates_attachment_content_type :asset, :content_type => ['image/gif', 'image/jpeg', 'image/png', 'image/x-ms-bmp'] end So basically I made this to

How to validate file content type to pdf, word, excel, and plain text for paperclip?

只愿长相守 提交于 2019-12-04 08:59:24
问题 In my model: has_attached_file :uploaded_file, :url => "/policy_documents/get/:id", :path => "/public/policy_documents/:id/:basename.:extension" validates_attachment_size :uploaded_file, :less_than => 10.megabytes validates_attachment_presence :uploaded_file validates_attachment_content_type :uploaded_file, :content_type =>['application/pdf', 'application/xlsx'], :message => ', Only PDF, EXCEL, WORD or TEXT files are allowed. ' And after this, it can upload only PDF documents, not excel or

Paperclip / Passenger NotIdentifiedByImageMagickError:

て烟熏妆下的殇ゞ 提交于 2019-12-04 08:04:36
When I try to upload a photo in Ruby on Rails using Paperclip on my local machine it works perfectly. When I try to upload a photo in Ruby on Rails using Paperclip on our Linux ( CentOS 5.2) server with Apache and Phusion Passenger , I get: 2 errors prohibited this user from being saved There were problems with the following fields: - Avatar /tmp/stream20091026-21120-1qdbnul-0 is not recognized by the 'identify' command. - Avatar /tmp/stream20091026-21120-1qdbnul-0 is not recognized by the 'identify' command. I tried adding: Paperclip.options[:command_path] = "/usr/local/bin" to production.rb

Can't upload image using Paperclip 4.0 Rails 3

陌路散爱 提交于 2019-12-04 07:52:54
I've installed ImageMagick and I've installed the gem Paperclip (version 4.0). I've added: Paperclip.options[:command_path] = 'C:\Program Files\ImageMagick-6.8.8-Q16' to the development.rb My photo.rb Model has this: has_attached_file :image validates_attachment_content_type :image, :content_type => ['image/jpeg', 'image/png', 'image/jpg'] I can choose a file in photos/new.html.erb but once I click on 'Create photo' button, the page reloads with a Paperclip specific error message saying: 1 error prohibited this photo from being saved: Image translation missing: en.activerecord.errors.models

Rails 5 on heroku forgets files stored with paperclip and turbolinks: No route matches

て烟熏妆下的殇ゞ 提交于 2019-12-04 06:26:09
问题 I have a blog with file up-/download via paperclip 5.1.0 and turbolinks 5.0.1. Upload without validation works fine now, but download is only working for a short period after upload. Afterwards an error (404) is displayed: The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved. If you are the application owner check the logs for more information. This did not help: heroku rake db:migrate heroku restart I am on production with mysql DB on

Remove question mark from Paperclip-generated files in Ruby on Rails 3.2.6

扶醉桌前 提交于 2019-12-04 05:10:12
I'm using Paperclip-FFMEG to upload video files to my development environment (and, eventually, to a local server when my project goes into production). When videos are uploaded, the filename is, by default, as follows: /system/modelnames/paperclipnames/.../mynewfile.mp4?xxxxxxxxxx I believe the 10 digit figure after the questionmark is a timestamp. However, the player I will be using to play the videos doesn't like to have anything after the file attachment - so I would like to strip the questionmark, and the timestamp after it, before passing the URL into the player. I tried to use the

Paperclip how to change basename (filename)?

安稳与你 提交于 2019-12-04 04:00:17
I am trying to change the basename (filename) of photos: In my model I have: attr_accessor :image_url, :basename has_attached_file :image, :styles => { :original => ["300x250>", :png], :small => ["165x138>", :png] }, :url => "/images/lille/:style/:id/:basename.:extension", :path => ":rails_root/public/images/lille/:style/:id/:basename.:extension" before_save :basename private def basename self.basename = "HALLLO" end But the filename is not changed at all. If you are assigning the file directly you can do this: photo.image = the_file photo.image.instance_write(:file_name, "the_desired_filename

Pixel RGB with ImageMagick and Rails

眉间皱痕 提交于 2019-12-04 03:57:05
问题 I'm currently uploading an image with PaperClip and ImageMagick. I would like to get the image's average color so I'm doing this (with a before_create hook): def get_average_color img = Magick::Image.read(self.url).first pix = img.scale(1, 1) averageColor = pix.pixel_color(0,0) end This works but when I try to print the pixel colors out I get them like this: red=36722, green=44474, blue=40920, opacity=0 How can I get these RGB values into regular (0-255) RGB values. Do I just mod them? Thanks