Search Results

Search found 152 results on 7 pages for 'paperclip'.

Page 3/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • RoR - Paperclip - How to set minimal width of an attachement

    - by sNiCKY
    Hi, my layout's requirement is to keep all thumbnails at 80px height, not higher, not smaller. In my model I set the style to :thumb= "500x80", so basically almost every picture which is not too wide gets its perfect miniature with 80px height. Sometimes, however, my pictures are narrow and high, so the thumb can have unclickable dimensions of like 5x80. So I dont want to crop pictures as long as thumbnails are not getting crazy narrow, but I think I can make a little sacrifice and crop them if thumb's width is getting smaller than 25px. So my questions is - is it possible in paperclip to set minimal proportions of a picture by which the style will be "500x80" and beyond that it will turn to sth like "25x80#"?

    Read the article

  • Paperclip - Validate File Type but not Presence

    - by Lowgain
    I am using paperclip to handle my file uploads, and in one situation I don't want the file to be mandatory. I do however want to make sure it is a specific file type when it is present. I have this: class TestModel < ActiveRecord::Base #stuff has_attached_file :sound #etc... validates_attachment_content_type :sound, :content_type => ['audio/mp3', 'application/x-mp3'] end And when I have no sound file present, it tells me it is not one of the valid content types. I've tried adding '' to the :content_type array, which also doesn't work! I also attempted creating a lambda procedure for the :if property, but I can't get it to run without some kind of error. Anything missing here?

    Read the article

  • Paperclip + ImageMagick on Windows 7: Image display fails when I add styles to attached_file in mode

    - by Brian Roisentul
    I'm working with Ruby on rails 2.3.8, NetBeans IDE. I've installed paperclip and I could show/save images successfully. Now, I've installed ImageMagick-6.6.2-4-Q16(for windows 7, 64bits). Until that moment, my model looked like this(and worked fine): has_attached_file :photo Now, after installing ImageMagick, when I add the :style line it fails: has_attached_file :photo, :styles => {:thumb => "100x100#", :small => "150x150>", :large => "400x400>" } and it throws the following error message when I try to upload an image: TypeError in ProfilesController#update backtrace must be Array of String The only thing I'm doing in the update action of that controller is the following: @profile.update_attributes(params[:profile]) @profile.update_attribute(:photo, params[:profile][:photo]) I've also installed miniMagick gem(because I read somewhere I had to do it). What am I missing?

    Read the article

  • Ruby on Rails: restrict file type with Paperclip using a flash uploader

    - by aperture
    I have a pretty basic Paperclip Upload model that is attached to a User model through has_many, and am using Uploadify to do the actual uploading. Flash sends all files with the content type of "application/octet-stream" so using validates_attachment_content_type rejects all files. In my create action, I am able to get the mime-type from the original file name, but only after it's been saved, with: def coerce(params) h = Hash.new h[:upload] = Hash.new h[:upload][:attachment].content_type = MIME::Types.type_for(h[:upload][:attachment].original_filename).to_s ... end and def create diff_params = coerce(params) @upload = Upload.new(diff_params[:upload]) ... end What would be the best way of white listing file types? I am thinking a before_validation method, but I'm not sure how that would work. Any ideas would be welcome.

    Read the article

  • Trying to get paperclip to refresh or reprocess..

    - by Trip
    I have over time, changed the size for thumbs of the class Deal. Through these changes, users were uploading to the site, so there are few people who have different sized thumbs. I wanted to reprocress or refresh these, so I went to into my root and typed: $ rake paperclip:refresh class=Deal Did nothing for the thumb sizes.. Then I : irb Deal.find(987).reprocess! Returned this : NoMethodError: undefined method `reprocess!' for #<Deal:0xb68a0988> from /data/HQ_Channel/releases/20100607130346/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:260:in `method_missing' from (irb):7 My deal class is this : => Deal(id: integer, organization_id: integer, deal: string, value: string, what: string, description: string, image_file_name: string, image_content_type: string, image_file_size: integer, image_updated_at: datetime, created_at: datetime, updated_at: datetime, deal_image_file_name: string, deal_image_content_type: string, deal_image_file_size: integer, deal_image_uploaded_at: datetime) What can i do to have it reprocess the original to make the thumb the correct size in the current thumb size params?

    Read the article

  • Dynamic use of :default_url in Paperclip

    - by dgilperez
    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/:style/#{self.category.name]}.png", :styles => { :large => "600x400>", :medium => "300x200>", :small => "100x75>", :thumb => "60x42>" } end class Category < ActiveRecord::Base attr_accessible nil has_many :services end In my view, image_tag service.logo.url(:thumb) outputs: undefined method `category' for #<Class:0x0000010a731620> Any ideas? EDIT2: A working default_url is :default_url => "/logos/:style/missing.png", SOLUTION: See my own answer below.

    Read the article

  • Update paths of already-created Paperclip attachments

    - by Horace Loeb
    I used to have this buggy Paperclip config: class Photo < ActiveRecord::Base has_attached_file :image, :storage => :s3, :styles => { :medium => "600x600>", :small => "320x320>", :thumb => "100x100#" }, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => "/:style/:filename" end This is buggy because two images cannot have the same size and filename. To fix this, I changed the config to: class Photo < ActiveRecord::Base has_attached_file :image, :storage => :s3, :styles => { :medium => "600x600>", :small => "320x320>", :thumb => "100x100#" }, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => "/:style/:id_:filename" end Unfortunately this breaks all URLs to attachments I've already created. How can I update those file paths or otherwise get the URLs to work?

    Read the article

  • rails paperclip unable to access image from another view

    - by curiousCoder
    my app has an habtm relation b/w listings and categories. now from the categories index page, a user filters select box to view listings in the show page. now i am not able to access images attached to listings in the category show page. listing.rb attr_accessible :placeholder, :categories_ids has_and_belongs_to_many :categories has_attached_file :placeholder, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png", :url => "/system/:hash.:extension", :hash_secret => "longSecretString" categories controller def index @categories = Category.all end def show @categories = Category.find_by_sql ["select distinct l.* from listings l , categories c, categories_listings cl where c.id = cl.category_id and l.id = cl.listing_id and c.id in (?,?)" , params[:c][:id1] , params[:c][:id2]] end the sql just filters and displays the listings in show page where i can show its attributes, but cant access the placeholder. note the plural @categories in show categories show page <ul> <% @categories.each_with_index do |c, index| %> <% if index == 0 %> <li class="first"><%= c.place %></li> <%= image_tag c.placeholder.url(:thumb) %> <li><%= c.price %></li> <% else %> <li><%= c.place %></li> <li><%= c.price %></li> <%= image_tag c.placeholder.url(:thumb) %> <% end %> <% end %> </ul> Access image from different view in a view with paperclip gem ruby on rails this said to make the object plural and call a loop, wch shall allow to access the image. it does not work in this case. undefined method `placeholder' for #<Category:0x5c78640> but the amazing thing is, placeholder will be displayed as an array of all images for all the listings if used as suggested in that stackoverflow, wch is, obviously, not the way i prefer. where's the issue? what am i missing?

    Read the article

  • Get paperclip to crop the image without validating

    - by Micke
    Hello fellow stackoverflow members. I have been following this guide to enable users to have their own avatar. But i have bumped in to a litle problem. When the user is cropping the image the model tries to validate all my validations. My user model looks like this: class User < ActiveRecord::Base has_attached_file :avatar, :styles => { :small => "100x100>", :large => "500x500>" }, :processors => [:cropper] attr_accessor :password, :crop_x, :crop_y, :crop_w, :crop_h attr_accessible :crop_x, :crop_y, :crop_w, :crop_h validates_confirmation_of :password validates_presence_of :password And when the user runs the crop updating script the user model tries to validate the password. But because i have no password field on the cropping page it can't validate it. Here is the updating of the crop: @user = User.find(current_user.id) if @user.update_attributes(params[:user]) flash[:notice] = "Successfully updated user." end How can i bypass this in a easy and clean way?

    Read the article

  • Help on using paperclip plugin

    - by Brian Roisentul
    I've just installed this plugin, created the migrations, added everything I needed to make it work(I didn't install ImageMagick yet). The problem is when I get the upload control parameter to save it in my controller, I get something like this: #<File:C:\Users\Brian\AppData\Local\Temp\RackMultipart.2560.6677> instead of a simple string, like C:\Users\Brian\AppData\Local\Temp\RackMultipart.2560.6677 And if I try to read it I get the following exception: TypeError backtrace must be Array of String What am I doing wrong? How do I read it or simply get rid of the # and < symbols?

    Read the article

  • Dynamic Attachment Size for Paperclip (Rails)

    - by CalebHC
    Is there anyway to have the validates_attachment_size except a dynamic file size limit? Here's an example: class Document < ActiveRecord::Base belongs_to :folder has_attached_file :document validates_attachment_size :document, :less_than => get_current_file_size_limit private def get_current_file_size_limit 10.megabytes # This will dynamically change end end I've tried this but I keep getting an error saying "unknown method". Lambdas and Procs don't work either. Has anyone ever tried this? Thanks

    Read the article

  • Imagemagick Resizing in Paperclip

    - by jonathan.soeder
    So, I want to resize images to a FIXED width, but proportional height. I have been trying a wide range of operators: 380x242# 380x242 380!x242 380x242< none of them have the desired effect. Any help? I want it to fill or resize to the 380 width, then resize / shrink the height by the same factor it used to shrink or resize the image to 380 wide.

    Read the article

  • Paperclip renaming files after they're saved

    - by fivetwentysix
    How do I rename a file after is has been uploaded and saved? My problem is that I need to parse information about the files automatically in order to come up with the file name the file should be saved as with my application, but I can't access the information required to generate the file name till the record for the model has been saved.

    Read the article

  • Question about Paperclip for Rails

    - by sev
    I'm using Papeclip(2.3.1.1) with Rails(2.3.5). In my view I write so: <%= link_to image_tag(p.attachment.url(:small)), p.attachment.url(:original) %, and it becomes into href="/system/attachments/1/original/1.JPG?1270134617 (for a tag) src="/system/attachments/1/small/1.JPG?1270134617" (for img tag). And when I click on the picture, my browser (Firefox) offers me to save or open picture and I want to just open picture in browser without any dialogs. I think it's because link contains ?1270134617 after file's name. How can I fix it?

    Read the article

  • Rails - Paperclip, getting width and height of image in model

    - by Corey Tenold
    Trying to get the width and height of the uploaded image while still in the model on the initial save. Any way to do this? Here's the snippet of code I've been testing with from my model. Of course it fails on "instance.photo_width". has_attached_file :photo, :styles => { :original => "634x471>", :thumb => Proc.new { |instance| ratio = instance.photo_width/instance.photo_height min_width = 142 min_height = 119 if ratio > 1 final_height = min_height final_width = final_height * ratio else final_width = min_width final_height = final_width * ratio end "#{final_width}x#{final_height}" } }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => ":attachment/:id/:style.:extension", :bucket => 'foo_bucket' So I'm basically trying to do this to get a custom thumbnail width and height based on the initial image dimensions. Any ideas?

    Read the article

  • How can I move deleting photos to the background with delayed_job and paperclip

    - by Tam
    I let my users create photo albums with many photos. Relationship as follows: has_many :album_photos, :dependent => :destroy i upload photos to S3 When the user delete album I want to delete all photos as the relationship shows but it takes time if the user has many photos. Can I automatically set photo deletion to happen in the background (delayed_job) without having to manually call 'send_later' on every photo?

    Read the article

  • Why would paperclip not assign an ID to my uploaded photos?

    - by Trip
    I just deployed to a cluster server, and my delayed_jobs recipe was overwritten in the process. I solved that, delayed_jobs is up and running but can't find the ID of images that are uploaded. The images are saved correctly : Processing PhotosController#create (for 173.161.167.41 at 2010-06-01 05:09:14) [POST] Parameters: {"Filename"="1.jpg", "gallery_id"="1298", "action"="create", "amp"=nil, "authenticity_token"="qmbnpwFY8a5E3YtS/4fMWF/Z8evCE4hMxqKVJw0I7Ek=", "Upload"="Submit Query", "controller"="photos", "organization_id"="470", "_hq_channel_session"="BAh7CSIYdXNlcl9jcmVkZW50aWFsc19pZGkHIhV1c2VyX2NyZWRlbnRpYWxzIgGAOGRlZDc0NGJlOWU3NTNlNDFlYmVlMDdjMzIzYjA1ZjQxNGE5ZDY4YjNmYjFmNjNkMDQ2OWY2ZDQyOTljZDhiMDFlNmRkMDljNThmMzBmOWJhMTIwNDhkMDI5MTMxYmU5MDczYjIxZmI4YmQxMDVlMTBmNjZmOWFhODE1ZTBjMGM6EF9jc3JmX3Rva2VuIjFxbWJucHdGWThhNUUzWXRTLzRmTVdGL1o4ZXZDRTRoTXhxS1ZKdzBJN0VrPToPc2Vzc2lvbl9pZCIlMjAwMDQ3ZDQ3ZWUyZTgzODIxYzdjOGI3OTdmZGJiMDM=--ac6aa580262938bf5a4d6b9a740722b680eb5d48", "Filedata"=#} [paperclip] Saving attachments. [paperclip] saving /data/HQ_Channel/releases/20100530153454/public/system/photos/9253/original/1.jpg [paperclip] Saving attachments. [paperclip] Saving attachments. Completed in 127ms (View: 2, DB: 91) | 200 OK [http://invent.hqchannel.com/organizations/470/media/galleries/1298/photos?_hq_channel_session=BAh7CSIYdXNlcl9jcmVkZW50aWFsc19pZGkHIhV1c2VyX2NyZWRlbnRpYWxzIgGAOGRlZDc0NGJlOWU3NTNlNDFlYmVlMDdjMzIzYjA1ZjQxNGE5ZDY4YjNmYjFmNjNkMDQ2OWY2ZDQyOTljZDhiMDFlNmRkMDljNThmMzBmOWJhMTIwNDhkMDI5MTMxYmU5MDczYjIxZmI4YmQxMDVlMTBmNjZmOWFhODE1ZTBjMGM6EF9jc3JmX3Rva2VuIjFxbWJucHdGWThhNUUzWXRTLzRmTVdGL1o4ZXZDRTRoTXhxS1ZKdzBJN0VrPToPc2Vzc2lvbl9pZCIlMjAwMDQ3ZDQ3ZWUyZTgzODIxYzdjOGI3OTdmZGJiMDM%3D--ac6aa580262938bf5a4d6b9a740722b680eb5d48&authenticity_token=qmbnpwFY8a5E3YtS%2F4fMWF%2FZ8evCE4hMxqKVJw0I7Ek%3D] And then delayed_jobs keeps spinning around in circles on this one : 2010-06-01T05:09:02-0700: * [Worker(delayed_job host:ip-10-251-197-159 pid:19994)] acquired lock on PhotoJob 2010-06-01T05:09:02-0700: * [JOB] delayed_job host:ip-10-251-197-159 pid:19994 failed with ActiveRecord::RecordNotFound: Couldn't find Photo with ID=9247 - 0 failed attempts 2010-06-01T05:09:02-0700: * [Worker(delayed_job host:ip-10-251-197-159 pid:19994)] acquired lock on PhotoJob 2010-06-01T05:09:02-0700: * [JOB] delayed_job host:ip-10-251-197-159 pid:19994 failed with ActiveRecord::RecordNotFound: Couldn't find Photo with ID=9245 - 0 failed attempts 2010-06-01T05:09:02-0700: * [Worker(delayed_job host:ip-10-251-197-159 pid:19994)] acquired lock on PhotoJob So what I get is that the photos are not being assigned ID's by paperclip. Anyone know where I could poke and pry from here? UPDATE: I created a clone application on a single server. And there are no problems. The images on the cluster do show up (occassionally). If I keep clicking on the folders that lead to photos, it will 50% of the time return a 404 with it not being able to find the photo, and the other half it will present the photo. So the problem has got to be with the server interaction between the ActiveRecord through multiple servers.

    Read the article

  • where from does paperclip get the name of original file?

    - by Pavel K.
    i started using nginx upload module (which creates upload files like /tmp/000121545) but i need paperclip to use original filename while saving files (like /public/avatars/LuckyLuke.jpg) previously in the parameters Rails were passing just "avatar"=>#<File:/tmp/RackMultipart20100413-6151-t3ecq0-0> no original filename as well, so i am wondering where from does it come in paperclip? i tried looking through plugin code but it's currently a bit too complex for me.

    Read the article

  • Remove unncessary error raised by paperclip - filename is not recognized by the 'identify' command.

    - by kgpdeveloper
    I've been searching on how to solve this issue but could not find any real and working solution. User model: validates_attachment_content_type :avatar, :content_type = ['image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/gif'] Unnecessary error shows up when invalid file type is uploaded: Avatar /tmp/sample,23283,0.txt is not recognized by the 'identify' command. Server details: Ubuntu and Debian which identify results to /usr/bin/identify Specifying command path does not solve the issue: Paperclip.options[:command_path] = "/usr/bin" Any ideas? I looked at geometry.rb file and there seems to be something wrong with it. def self.from_file file file = file.path if file.respond_to? "path" geometry = begin Paperclip.run("identify", %Q[-format "%wx%h" "#{file}"[0]]) rescue PaperclipCommandLineError "" end parse(geometry) || raise(NotIdentifiedByImageMagickError.new("#{file} is not recognized by the 'identify' command.")) end Let me know if anyone has solved the same issue and how. Many thanks.

    Read the article

  • Uploading an image file with Paperclip (in RoR) causing error.

    - by mtay
    This should be a simple thing to do, but I'm running into a wall and I'm not sure how to debug this response. In my Image model, I have: class Image < ActiveRecord::Base has_attached_file :image, :styles => { :display => "500x500>", :thumbnail => "95x95>"} Then in my Views, my form contains this: -form_for @image, :html => { :multipart => true } do |image| %tr %td.woc_left =label_tag :image, 'photo to upload', :class => 'required' %td.woc_center =image.file_field :image In my Mysql table, I have a column called "image_file_name" (string). However, when I try to upload an image and submit it, I see 2 errors prohibited this from being saved There were problems with the following fields: Image Paperclip::CommandNotFoundError Image Paperclip::CommandNotFoundError What am I doing wrong? Thank you for your help!

    Read the article

  • Does the '#' modifier for cropping images in Paperclip work only for square images?

    - by user3451384
    It is very well documented that you can create square thumbnails with center cropping with Paperclip (4) and Rails (4). I would like to have an image of very specific dimensions (e.g. 200x100) and if input an image of let's say 800x200 it is first resized to 400x100 and then the width (400) is cropped down to 200 pixel from the center (i.e. 100px cut from the right and 100 px cut from the left). I tried with 200x100# and it does not appear to work (i.e. the '#' has no effect). I have found that I could adapt other solutions such as this, but I was wondering if '#' is supposed to work only for cropping to square images, or is a Paperclip bug or I am doing something wrong...

    Read the article

  • How to pass additional convert options to paperclip on Heroku?

    - by Yuri
    UPD class User < ActiveRecord::Base Paperclip.options[:swallow_stderr] = false has_attached_file :photo, :styles => { :square => "100%", :large => "100%" }, :convert_options => { :square => "-auto-orient -geometry 70X70#", :large => "-auto-orient -geometry X300" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => ":attachment/:id/:style.:extension", :bucket => 'mybucket' validates_attachment_size :photo, :less_than => 5.megabyte end Works great on local machine, but gives me an error on Heroku: There was an error processing the thumbnail for stream.20143 The thing is I want to auto-orient photos before resizing, so they resized properly. The only working variant now(thanks to jonnii) is resizing without auto-orient: ... as_attached_file :photo, :styles => { :square => "70X70#", :large => "X300" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => ":attachment/:id/:style.:extension", :bucket => 'mybucket' ... How to pass additional convert options to paperclip on Heroku?

    Read the article

  • rails + paperclip: Is a generic "Attachment" model a good idea?

    - by egarcia
    On my application I've several things with attachments on them, using paperclip. Clients have one logo. Stores can have one or more pictures. These pictures, in addition, can have other information such as the date in which they were taken. Products can have one or more pictures of them, categorized (from the font, from the back, etc). For now, each one of my Models has its own "paperclip-fields" (Client has_attached_file) or has_many models that have attached files (Store has_many StorePictures, Product has_many ProductPictures) My client has also told me that in the future we might be adding more attachments to the system (i.e. pdf documents for the clients to download). My application has a rather complex authorization system implemented with declarative_authorization. One can not, for example, download pictures from a product he's not allowed to 'see'. I'm considering re-factoring my code so I can have a generic "Attachment" model. So any model can has_many :attachments. With this context, does it sound like a good idea? Or should I continue making Foos and FooPictures?

    Read the article

  • How can I set paperclip's storage mechanism based on the current Rails environment?

    - by John Reilly
    I have a rails application that has multiple models with paperclip attachments that are all uploaded to S3. This app also has a large test suite that is run quite often. The downside with this is that a ton of files are uploaded to our S3 account on every test run, making the test suite run slowly. It also slows down development a bit, and requires you to have an internet connection in order to work on the code. Is there a reasonable way to set the paperclip storage mechanism based on the Rails environment? Ideally, our test and development environments would use the local filesystem storage, and the production environment would use S3 storage. I'd also like to extract this logic into a shared module of some kind, since we have several models that will need this behavior. I'd like to avoid a solution like this inside of every model: ### We don't want to do this in our models... if Rails.env.production? has_attached_file :image, :styles => {...}, :storage => :s3, # ...etc... else has_attached_file :image, :styles => {...}, :storage => :filesystem, # ...etc... end Any advice or suggestions would be greatly appreciated! :-)

    Read the article

  • How do you crop a specific area with paperclip in Rails (3)?

    - by Smickie
    Hi, I have paperclip in Rails (3) working with simple cropping, for example the blow code makes a simple crop of the thumbnail: has_attached_file :image, :styles => { :thumb => "90x90#" }, :default_style => :thumb However I was wondering how do you crop a very specific area of an image; lets say you have an x and y coordinate to start from and then a width and height of the crop. How do you go about passing a complex style like this in? Thanks very much.

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >