paperclip

Multi-step form in Rails 3 with Paperclip attachments

房东的猫 提交于 2019-11-28 07:36:45
问题 I'm creating a multi-part form in the style that Ryan Bates describes here: http://railscasts.com/episodes/217-multistep-forms http://asciicasts.com/episodes/217-multistep-forms (text-based version) To summarize, I have one view (with a bunch of partials for each form step), and the form variables are stored in a session when the user clicks a next button and a different part of the form is displayed. One of my form steps allows the user to upload several images via the Paperclip gem. The

getting random error while upload photo with paperclip on my ftp server

与世无争的帅哥 提交于 2019-11-28 06:27:50
问题 I used gem "paperclip" for upload images and gem "paperclip-storage-ftp" for store images on my own ftp server. It worked fine for a while, but now I am getting random errors, when I upload photos. Sometimes this Net::FTPReplyError - 150 Connecting to port 3270 Sometime this Net::ReadTimeout - Net::ReadTimeout: Sometime this Paperclip::Storage::Ftp::NoServerAvailable .. and sometimes this: Net::FTPPermError - 500 ? Model class AlbumPhoto < ActiveRecord::Base has_attached_file :photo, { #

Allowing User to Download File from S3 Storage

核能气质少年 提交于 2019-11-28 05:05:11
Right now I am using Amazon S3 and Paperclip which is allowing my users to upload an image that is associated with the event they are creating. My ultimate goal is since others can view this event, to be able to click on the image and have it prompt a SAVE TO their computer. As of now, clicking the link will open the image in a browser window. I rather have it ask for them to download instead. All images only saved on S3, not local. Need to hide exposed s3 url as well if possible or camouflage it Here is my current setup Index.html <%= link_to 'Download Creative', event.creative.url, class:

Paperclip renaming files after they're saved

本秂侑毒 提交于 2019-11-28 04:24:49
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. If, for example, your model has attribute image: has_attached_file :image, :styles => { ...... } By default papepclip files are stored in /system/:attachment/:id/:style/:filename. So, You can accomplish it by renaming every style and then changing image_file

Accelerate S3 upload with paperclip

孤街醉人 提交于 2019-11-28 04:13:47
问题 I'm using paperclip for uploading images in S3. But I've noted that this upload is very slow. I think because before complete the submit the file has to pass by my server, be processed and be sent to the S3 server. Is there a method for accelerate this? thanks 回答1: Use delayed jobs, this is a good example here Or you can use flash upload. 回答2: Do you want to improve the appearance of the upload being faster or actually make the upload faster? If it's the former you can put your image handling

Rails 3, paperclip + S3 - Howto Store for an Instance and Protect Access

被刻印的时光 ゝ 提交于 2019-11-28 03:51:15
I have a Rails 3 app with paperclip, with the intent to store data on S3. In the app, Users belong to an instance. I would like the data stored across all the models per instance. And would like to prevent a user from Instance A from accessing, or being able to load data from Instance B. What's the best way to handle this? thanks I actually just implemented authorized S3 url's in my Ruby on Rails 3 application with Paperclip . Let me share how I accomplished this. So what I did, and what you probably want is quite easy to implement. Let me give you an example: FileObject model has_attached

Rails: Paperclip & previews?

时间秒杀一切 提交于 2019-11-28 03:43:16
You know on some sites when you're asked to upload, say, an avatar, you click on the button, select your file, then hit OK, but before you Submit the page (as in, no record is created/updated), a little preview of the image shows up? How would I accomplish this using Paperclip for Rails? Bonus points for anyone who can point me towards a tutorial or something that might tell me how to do a Javascript crop on the image before saving the record. I haven't been able to find much on Google on the subject... thanks for the help! This kind of thing is problematic from a Rails perspective because of

How can I get url for paperclip image in to_json

青春壹個敷衍的年華 提交于 2019-11-28 03:23:45
I have a model that uses paperclip like this: has_attached_file :avatar, :styles => { :large => "100x100>" , :medium => "50x50>", :small => "20x20>" }, :default_url => '/images/missing-owner_:style.png' I'm exporting this model with to_json method and I want to export the image url so I could use it in javascript. I know I can access the url like this in the view: <%= image_tag model.avatar.url(:medium) %> But How can I do the same in the to_json method. I have some like this: respond_to do |format| render :json => @model.to_json(:only => [:id,:name,:homephone,:cellphone]) end Ben Zittlau I

Delete an image with Paperclip

核能气质少年 提交于 2019-11-28 03:19:27
问题 I'm using Paperclip to save pictures in my Rails application: User model: class User < ActiveRecord::Base has_one :profile end Profile model: class Profile < ActiveRecord::Base has_attached_file :avatar, :styles => {:medium => "300x300>", :thumb => "100x100>"} belongs_to :user end I try to delete the avatar with: current_user.profile.avatar = nil current_user.profile.save but it doesn't work. Is it possible? 回答1: profile = current_user.profile profile.avatar.destroy profile.save You can't

Paperclip Error: model missing required attr_accessor for 'avatar_file_name'

允我心安 提交于 2019-11-28 02:45:01
问题 I then want to use Paperclip to have photos for each Listing. I added the appropriate code to the listings show.html.erb, the listing.rb model, the listings_controller.rb and the _form.html.erb partial. When I try uploading an image for the Listing I get this error: Paperclip::Error in ListingsController#update Listing model missing required attr_accessor for 'avatar_file_name' Line 44 of listings_controller: def update respond_to do |format| if @listing.update(listing_params) format.html {