paperclip

Paperclip in Rails 4 - Strong Parameters Forbidden Attributes Error

南楼画角 提交于 2019-11-27 18:03:47
问题 Having a problem with a Paperclip upload in Rails 4 - failing on ForbiddenAttributesError (strong parameters validation). Have the latest paperclip gem and latest rails 4 gems. I have a model "Image" with an attached file "upload" in the model: has_attached_file :upload, :styles => { :review => ["1000x1200>", :png], :thumb => ["100x100>", :png]}, :default_url => "/images/:style/missing.png" The image model was created with a scaffold, and I added paperclip migrations. The form partial was

Dynamic use of :default_url in Paperclip

∥☆過路亽.° 提交于 2019-11-27 17:51:55
问题 I'm trying to configure Paperclip to provide different missing images based on the instance's category attribute. Every category of the object has its own missing image. This is my first take: EDIT to add full models: class Service < ActiveRecord::Base attr_accessible :logo, :logo_file_name, :logo_content_type, :logo_file_size, :logo_updated_at belongs_to :category, :counter_cache => true has_attached_file :logo, :path => "/:id-:style-:filename", :url => ":s3_eu_url", :default_url => "/logos/

How to set a file upload programmatically using Paperclip

一个人想着一个人 提交于 2019-11-27 17:06:14
I have a rake task to seed an application with random data using the faker gem. However, we also have images (like logos) that we want uploaded in this rake task. We already have Paperclip set up, but don't have a way to upload them programmatically in a rake task. Any ideas? theIV What do you mean by programmatically? You can set up a method that will take a file path along the lines of my_model_instance = MyModel.new file = File.open(file_path) my_model_instance.attachment = file file.close my_model_instance.save! #attachment comes from our Paperclip declaration in our model. In this case,

Paperclip Error

限于喜欢 提交于 2019-11-27 16:10:12
问题 I'm getting the following error in my development.log [paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream28514-0 is not recognized by the 'identify' command.> And i've googled about this error and i found out that many people have solved this by adding this line Paperclip.options[:command_path] = "/usr/local/bin" However, i still get the same error even after adding that line! I've tried everything possible! Any help would be highly

Multiple files upload with Rails 3 and paperclip on heroku

别来无恙 提交于 2019-11-27 12:36:24
问题 I need an interface on my Rails 3 app to upload multiple files to Amazon S3 (because i'm on heroku), possibly with progress bars. I've easily managed how to set up paperclip and upload single files, but i'm really lost now on how to go ahead. Please can you give me some advices? It's 2 days i'm searching across all the internet, but i can't find a working solution ** EDIT ** I really can't understand... I'm going mad 'cause I'm losing too many hours on this... please help me. If I try to open

NameError (uninitialized constant Paperclip::Storage::S3::AWS):

廉价感情. 提交于 2019-11-27 12:15:47
I'm trying to incorporate images into my web app and I keep running into this error after removing quite a few features. It came down to my 'create' application controller and I'm not entirely sure where I should go from here. 2015-02-06T20:30:12.292187+00:00 app[web.1]: (1.9ms) ROLLBACK 2015-02-06T20:30:12.296299+00:00 app[web.1]: NameError (uninitialized constant Paperclip::Storage::S3::AWS): 2015-02-06T20:30:12.296301+00:00 app[web.1]: app/controllers/articles_controller.rb:24:in `create' 2015-02-06T20:45:14.691084+00:00 app[web.1]: [paperclip] saving /articles/images/000/000/013/original

Paperclip::Errors::MissingRequiredValidatorError with Rails 4

只愿长相守 提交于 2019-11-27 10:05:22
I'm getting this error when I try to upload using paperclip with my rails blogging app. Not sure what it is referring to when it says "MissingRequiredValidatorError" I thought that by updating post_params and giving it :image it would be fine, as both create and update use post_params Paperclip::Errors::MissingRequiredValidatorError in PostsController#create Paperclip::Errors::MissingRequiredValidatorError Extracted source (around line #30): def create @post = Post.new(post_params) This is my posts_controller.rb def update @post = Post.find(params[:id]) if @post.update(post_params) redirect_to

Simple cropping with Paperclip

北战南征 提交于 2019-11-27 09:50:49
问题 I would like to crop images on upload using Paperclip to get square thumbs from the center of the original picture. I find out a method in documentation that seems to do exactly what I want: transformation_to(dst, crop = false) The problem is that I can't figure out where to use this method. It would be great to simply pass something as a parameter here: has_attached_file :picture, :styles => { :medium => "600x600>", :thumb => "something here" } 回答1: You only need to use # instead of > as a

Validation failed: Upload file has an extension that does not match its contents

柔情痞子 提交于 2019-11-27 07:53:57
I am using paperclip gem to upload files. and my paperclip gem version is paperclip-4.1.1. While uploading a file its throwing Validation failed: Upload file has an extension that does not match its contents. I am trying to upload a xlsx file. and also i have mentioned that into the model content_type. validates_attachment_content_type :upload_file, :content_type => %w(application/msword application/vnd.ms-office application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet), :message => ', Only XML,EXCEL files are allowed. ' I don't know why this error is

Default_url in Paperclip Broke with Asset Pipeline Upgrade

大兔子大兔子 提交于 2019-11-27 07:25:35
I'm using Paperclip and have a default_url option like this for one of my attachments: :default_url => '/images/missing_:style.png' The asset pipeline obviously doesn't like this since the directories moved. What's the best way to handle this? I have two styles for this picture (:mini and :thumb). :default_url => ActionController::Base.helpers.asset_path('missing_:style.png') Then put the default images in app/assets/images/ Tested only on Rails 4. To make it work in production, we have to pass the name of an existing file to the asset_path helper. Passing a string containing a placeholder