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 update' app/controllers/users_controller.rb:64:inupdate'

In my User model, I have

attr_accessible :avatar

has_attached_file :avatar, 
        :styles => { 
          :large => "500x500>", 
          :medium => "213x213>", # profile image
          :thumb => "50x50>",
          :smaller => "30x30>" }, 
          :processors => [:cropper],
         # tells paperclip how to crop the image  
        :storage => :s3,
        :s3_credentials => "#{Rails.root}/config/s3.yml", # TODO 
        :path => ":attachment/:id/:style/:basename.:extension",
        :bucket => 'eventsbucket'

The error persists whether I include the S3 info or not. In my migration I have,

class AddAvatarColumnsToUsers < ActiveRecord::Migration
  def self.up
    add_attachment :users, :avatar
  end

  def self.down
    remove_attachment :users, :avatar
  end
end

Lastly, in my Users controller update action, I have

def update
    respond_to do |format|
      if @user.update_attributes(params[:user])
        sign_in @user
        format.html { redirect_to @user, notice: 'Profile Successfully Updated' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
   end
end

In my Gemfile I have gem "paperclip", "~> 3.1.4" (UPDATE: I've since pulled Paperclip straight from thoughtbot and problem persists). I've run bundle install. I've run db:migrate. I've read this StackOverflow entry, but the error persists whether I include "multipart => true" or not. When I tried the Emerson Lackey Tutorial, it worked up to the point where he tried to display the output of the "5.times..." command.

I'm interested in both getting Paperclip to work and understanding just what a "NoHandlerError" is and how to avoid it in the future.


回答1:


Did you try the railscasts episode # 134 ?

http://railscasts.com/episodes/134-paperclip?view=asciicast



来源:https://stackoverflow.com/questions/12336081/nohandlererror-with-rails3-and-paperclip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!