paperclip

Undefined method has_attached_file after Paperclip installation?

拜拜、爱过 提交于 2019-12-23 19:34:09
问题 Not sure if I've done everything right here. I added the Paperclip gem to my Gemfile and did bundle install. I followed along with the readme instructions on Paperclips Github page. I wasn't sure if I needed to install ImageMagick. But, I found a script on Github for installation on Snow Leopard, so I ran: rails plugin install http://github.com/masterkain/ImageMagick-sl.git But, now I'm getting Undefined method has_attached_file I'm completely new to Rails and programming. Most of this is

how to remove existing style dimensions in paperclip

ⅰ亾dé卋堺 提交于 2019-12-23 17:19:19
问题 I know you can add new styles to paper clip and then use process! method to force paperclip to fill in the missing styles. But what if you want to ditch the old styles that you are not using any more. For example I have styles iphone and ipad, and I changed my mind and would instead like :large and :medium with slightly different dimensions instead of :iphone and :ipad. In particular I'm hosting my images on s3 since my app is on heroku. I would like to remove all the folders on s3 pertaining

Paperclip does not save attachment

微笑、不失礼 提交于 2019-12-23 13:25:34
问题 I am new in Rails and web development... I have created a User model, and I am now trying to give the user the ability to add a profile picture, using Paperclip. From my user show page, a user can click on a link to open an 'edit' page, from which he can see a form to browse and choose an image to upload. When clicking on the button, it calls the 'update' action and redirect to the user show page, but the image is not saved in any folder, and the image attributes (filename, contenttype,

NoHandlerError with Rails3 and Paperclip

末鹿安然 提交于 2019-12-23 13:08:14
问题 So this is my first question on StackOverflow. I'm trying to implement Paperclip on Rails 3.2.3, and after clicking "submit" to create a profile with an uploaded image, I get: Paperclip::AdapterRegistry::NoHandlerError in UsersController#update No handler found for "Screen Shot 2012-09-01 at 11.03.43 AM.png" My server log reads, Paperclip::AdapterRegistry::NoHandlerError (No handler found for "Screen Shot 2012-09-01 at 11.03.43 AM.png"): app/controllers/users_controller.rb:65:in block in

how to hook for destroy of a model that belongs to another model?

巧了我就是萌 提交于 2019-12-23 12:51:48
问题 I have a User model which has_many experiments: class User < ActiveRecord::Base has_many :experiments, :dependent => :destroy and Experiment model: class Experiment < ActiveRecord::Base belongs_to :user has_attached_file :thumbnail I want to hook for destroy moment at the Experiment model after the owner User get destroyed. (ex user cancel his account) I need to do so to delete the attachment image of the Experiment model, which is stored at amazon. like experiment.thumbnail.destroy What is

Rails PaperClip Attachments, knowing if there's a image thumbnail?

淺唱寂寞╮ 提交于 2019-12-23 12:30:46
问题 I'm using Rails 3 paperclip and allow users to upload attachments to the attachment model. If the file is an image, the app generates image previews. If the file is not, it only uploads the file (no image previews). Now I would like to display a list of all the attachments in the DB. So I use attachment.attachment(:large) and that works fine for image attachments, but errors (obviously) for non-image attachments. What's a good way to check if it's an image attachment or not? If not, I'd like

Fixtures with Paperclip

巧了我就是萌 提交于 2019-12-23 08:57:19
问题 I'm using Paperclip to store documents, but I can't find how to create fixtures of them, I wrote this : <% doc = Document.create(:asset => File.open(Rails.root.join('spec', 'assets', 'image.png'))) %> <%= part_event_image %>: asset_file_name: <%= doc.asset_file_name %> asset_content_type: <%= doc.asset_content_type %> asset_file_size: <%= doc.asset_file_size %> asset_updated_at: <%= doc.asset_updated_at %> documentable: party (Event) %> <% end %> But one I ran it, the document exist in the

Paperclip configurations | Old Attachments

ⅰ亾dé卋堺 提交于 2019-12-23 05:15:08
问题 I recently changed my Paperclip configurations: New Configs: has_attached_file :scr, :styles => { :index => "215x165#", :show => "900" }, processors: [:thumbnail, :compression], :content_type => { :content_type => ["image/jpg", "image/png"] } Old Configs: has_attached_file :scr, :styles => { :index => "215x165# For Showing the Pictures i need on my App i use the :show attribute. The Problem is that my app has already a lot of pictures and upon changing the configs the pictures are not longer

Rails - Attaching image through paperclip on nested fields causes unwanted/unavoidable redirect_to

谁说胖子不能爱 提交于 2019-12-23 05:12:04
问题 I have a form in my project for a model Artworks where I am using fields_for for a resource Photo where Artworks has_many :photos . The Photo model uses paperclip to attach images. All my forms are AJAX based, meaning the page should never be reloaded, and I shouldn't be using redirect_to anywhere in my controllers (and I'm not). When I include the fields_for in my form with the paperclip file_field, if I create or update the photo when I submit the form, I get the following error: Template

content-type validation with paperclip fails

戏子无情 提交于 2019-12-23 04:37:10
问题 I'm trying to use paperclip to upload .xm files which should have the mime type audio/x-mod . I configured paperclip to allow this configuration by setting the following options: Paperclip.options[:content_type_mappings] = { xm: "audio/x-mod" } The validation for the attachment field looks like this: validates_attachment :song, presence: true, content_type: { content_type: ["audio/x-mod"] }, size: { in: 0..128.kilobytes } Whenever I try to upload a .xm file that has the mime type audio/x-mod