paperclip

no validates_attachment_file_name when upgrading to Paperclip 4.1 from 3.5

时光总嘲笑我的痴心妄想 提交于 2019-12-05 19:49:05
We have code that looks like run of the mill paper clip: has_merchants_attached_file :pdf, storage: :s3, s3_credentials: Mbc::DataStore.s3_credentials, s3_permissions: :private, path: ":identifier_template.pdf", bucket: Mbc::DataStore.forms_and_templates_bucket_name validates_attachment_file_name :pdf, :matches => [/pdf\Z/] Which generates an error: undefined method `validates_attachment_file_name' for #<Class:0x007fba67d25fe0> Interestingly enough, when we down grade back to 3.5, we encounter the same issue. The controller that is generating this is: def index @fidelity_templates =

How to set up Amazon S3, paperclip, and ENV variables

拥有回忆 提交于 2019-12-05 18:36:34
I have tried many different ways to set up S3 using ENV variables for image uploads and cannot get it to work. I know my keys and bucket name work, because when I put them straight into the code, my images upload correctly. However, when I try to switch to ENV variables, things do not work. I used the figaro gem, which created application.yml. In that file, I have: S3_BUCKET_NAME "xxxxx" AWS_ACCESS_KEY_ID: "AAAAAAAAA" AWS_SECRET_ACCESS_KEY: "BBBbbbBBBB" Not sure if there should be any quotation marks there or not, but right now, I have them in. I have tried without, also. In my model (listing

paperclip inputs and previews for uploaded images in edit action

那年仲夏 提交于 2019-12-05 17:47:02
I am using paperclip and rails 4 and multiple image uploading works correctly. However I would like to configure it to allow uploading of a maximum of 3 images and only show inputs and previews for uploaded images. If I upload an image out of the 3 possible images.. and then go to the edit action.. it still shows 3 upload input elements instead of 2. And all of them say "no file chosen" which is not good for the user. The user might replace the image while thinking they are adding a new one. How can I modify my edit action or my form so that for filled assets , the choose file input actually

Paperclip - undefined method `match' for nil:NilClass

为君一笑 提交于 2019-12-05 16:37:05
I'm new to rails, and ruby. I'm creating a simple application where I can upload a photo. I have the paperclip gem installed and I'm trying to configure it within my model to specify a thumbnail size like so: has_attached_file :photo, :styles => {:thumb => '120x120>', :large => '640x480>' }, :default_style => :thumb, :url => "/system/photos/:basename.:extension", :path => ":rails_root/public/system/photos/:basename.:extension" However, I keep receiving the error: undefined method `match' for nil:NilClass When I remove the :styles parameter, everything works as expected. Can anybody shed some

Paperclip Error: uninitialized constant Paperclip (NameError)

三世轮回 提交于 2019-12-05 16:31:46
Trying to install paperclip (the cloudfiles fork), but getting an error: config/enviroments/development.rb:28:in 'block in <top (required)>': uninitialized constant Paperclip (NameError) This is how I installed everything. gemfile: gem 'cloudfiles', '>=1.4.9' gem 'paperclip-cloudfiles', '~>2.3' config/environment.rb config.gem 'paperclip-cloudfiles', :lib => 'paperclip' config/enviroments/development.rb Paperclip.options[:command_path] = "/ImageMagick/6.6.9-Q16/" #ImageMagick is at c:/ImageMagick/.. I'm not sure if this will solve your problem, but if you're using Bundler, you don't need to

How to upload file via the JSON interface in Rails

一笑奈何 提交于 2019-12-05 16:26:23
I have a web service in Rails which among all else should provide file upload functionality to the clients. The clients all use JSON to talk to the webservice. I use the Paperclip plugin for upload management. The problem is I do not know how to upload a file via JSON. All works in the web formular, but I cannot find information on how to consctruct my JSON Request to send files to the server. Can somebody help out? Regards, Angel Kafazov You don't need to use Paperclip for uploading JSON files in rails. Use the following syntax inserting the file upload field to your view. To read the JSON

Ruby: Paperclip, S3, and Deep-cloning

非 Y 不嫁゛ 提交于 2019-12-05 16:09:20
What I have is a Theme model, which contains many Assets. Assets are using Paperclip and storing their file content in my Amazon AWS-S3 system. I'm also using deep_clone because my customers have the ability to copy built in Themes and then modify them to their hearts content. All the deep_clone stuff is working great, but when I deep_clone the assets, the old file contents don't get added to my S3 buckets. The record gets saved to the database, but since the file-contents don't get saved with the new ID the file.url property points to a dead file. I've tried calling paperclip's save and

Paperclip - Default Style per Style? Possible

怎甘沉沦 提交于 2019-12-05 14:33:28
I'm using paperclip, and have several styles: :styles => {:large => "300x300>", :medium => "150x150>", :small => "50x50>", :thumb => "30x30>" } The issue is default_stype, only applies to one of the sizes... :default_style => :thumb, :default_url => url here.... How can I set default_stypes for each style type? so if I call: <%= image_tag @user.profile_pic.url(:large) %> The LARGE style has a default_url? Thanks I Would suggest to use has_attached_file :xyz, :url => "/assets/:id", :path => ":rails_root/assets/photos/:attachable_type/:attachable_id/:id/:basename_:style.:extension", :styles => {

Can't Save Image Attributes with Paperclip in Rails 4

自古美人都是妖i 提交于 2019-12-05 13:11:36
I have two associated models in my Rails 4 app: product.rb and image.rb . The Image model allows attached files using the Paperclip gem. Images belong_to a Product, and a product has_many Images. I would like to use the Product's new view to create and attach an image when I create a product. Each time I try, the parameters associated with the Paperclip image do not get saved, and end up nil . Here are the models: Product.rb class Product < ActiveRecord::Base validates :name, :part_number, presence: true has_many :images, dependent: :destroy belongs_to :category accepts_nested_attributes_for

Where does heroku store uploaded files when using paperclip

拟墨画扇 提交于 2019-12-05 10:49:53
I have created a simple ROR application and installed paperclip with this configuration has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:id/:filename", :url => "/system/:attachment/:id/:filename then i created a simple form that takes the file as input from the user web browser, after that the file url is being displayed model.attachment.url and the user can download the file again. I tried to run some linux commands to know where are downloaded files are stored 'ls /app/public/system/attachments/' but couldn't all my uploaded files. Also some files are being