paperclip

Paperclip - Default Style per Style? Possible

╄→гoц情女王★ 提交于 2019-12-12 09:44:25
问题 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 回答1: I Would suggest to use has_attached_file :xyz, :url => "/assets/:id", :path

undefined method `stringify_keys'

邮差的信 提交于 2019-12-12 07:39:14
问题 When I try to upload image using Paperclip gem I got this error: NoMethodError (undefined method `stringify_keys' for <ActionDispatch::Http::UploadedFile:0x000000025387f0>) class MenuItem < ActiveRecord::Base has_one :image end class Image < ActiveRecord::Base belongs_to :menu_item has_attached_file :image, :styles => { :large => "640x480", :medium => "300x300", :thumb => "100x100" } end 回答1: I've seen this error happen before, usually when people attempt to call update_attributes like this:

Paperclip, Delayed Job, S3, Heroku - design for delayed processing of sensitive uploaded files: db or s3?

ぃ、小莉子 提交于 2019-12-12 07:29:05
问题 I need feedback on the design for uploading and delayed processing of a file using heroku, paperclip, delayed job and, if necessary, s3. Parts of it have been discussed in other places but I couldn't find a complete discussion anywhere. Task description: Upload file (using paperclip to s3/db on heroku). File needs to be private as it contains sensitive data. Queue file for processing (delayed job) Job gets run in queue File is retrieved (from s3/db), and processing is completed File is

Routing Error with Rails 3 Paperclip and S3

风格不统一 提交于 2019-12-12 05:03:58
问题 I followed this tutorial exactly and received the following error after trying to upload a JPG to my local environment (I have not pushed to Heroku yet): ActionController::RoutingError (No route matches "/logos/medium/missing.png") I checked similar tutorials and none of them mentioned requiring routes for your remote images. Like I said, I have triple-checked this tutorial and I'm doing everything it asks of me, so what steps could I be missing here? The ONLY difference is that I already had

Cannot upload files to Cloudinary

半世苍凉 提交于 2019-12-12 04:58:35
问题 Cloudinary won't let me upload XLS files when it says they support it. I'm using the Heroku add-on. C:\Users\Chloe\workspace\fortuneempire>rails console Loading development environment (Rails 5.0.2) irb(main):001:0> Cloudinary::Uploader.upload('C:\Users\Chloe\Documents\Chocolate_Store1.xls') CloudinaryException: Invalid image file from C:/ruby23/lib/ruby/gems/2.3.0/gems/cloudinary-1.8.0/lib/cloudinary/uploader.rb:336:in `block in call_api' http://cloudinary.com/faq Can I host any type of

Paperclip :url does not create Routes

╄→гoц情女王★ 提交于 2019-12-12 04:57:29
问题 What is the point of using the :url option with paperclip? The :path option does in fact change the location where the file is saved, but the :url option doesn't seem to do a thing. It only works when it points to a publicly accessible file location. At that point, the url is already accessible to anyone. If I change the url so that it doesn't match the path, it does not work. As far as I can tell, it does not create any routes either way. Is there something I am missing here. What is the

rails 3.2 skip paperclip attachment presence validation on edit action

佐手、 提交于 2019-12-12 04:46:09
问题 I am new to Rails and i'm working on my first rails application that uses paperclip for attachments and i'm validating the presence of attachment using validates_attachment :avatar, presence: true which is working perfectly well on create action, but when a user is editing his account settings and doesn't upload a new avatar, there is an error for not having avatar uploaded but i want to skip that validation on edit and only validate on edit if user uploads a new one to replace existing one.

no implicit conversion of String into Array - Rails 4.1.0.beta1

廉价感情. 提交于 2019-12-12 04:30:57
问题 I have been dealing with an issue where I get the error: "no implicit conversion of String into Array". To put this in context: I am on Rails 4.1.0.beta1, and I am using Paperclip. I am trying to add a watermark to my images. I found the following solution: Watermark images with paperclip, rails 4 I sort of got it working at some point last night after receiving the here stated error message - then I made a slight change, which I had undone. And now I get the following error again?! It might

How to use paperclip with devise to add profile photo?

时光怂恿深爱的人放手 提交于 2019-12-12 04:19:07
问题 Creating a pinterest-like app where users can create a pin with an image, title, and description is easy with paperclip. But I'm having trouble modifying the paperclip docs when I want to use it as a way to upload a profile picture when I'm using devise. Any tips? 回答1: Try the following code. In your users/registrations/new.html.erb view file add the following code. <%= form_for @user, url: users_path, html: { multipart: true } do |f| %> <%= f.file_field :avatar %> <% end %> In your devise's

Rails: prevent submitting form if field is blank

点点圈 提交于 2019-12-12 03:49:08
问题 I am creating product page, where user can upload more than one photo of product. To create and edit product, i am rendering a form file. For uploading photos, i have used nested_fields for photos in the form of the product. Here is how photo code in the form looks like: <%= f.fields_for :photos do |photo| %> <%= image_tag photo.object.avatar.url(:thumb), unless f.object.new_record? or photo.object.new_record? %> <%= photo.file_field :avatar, :style => "none" %> <%= photo.link_to_remove