使用 Rails3 和 Paperclip 的 NoHandlerError [英] NoHandlerError with Rails3 and Paperclip

查看:45
本文介绍了使用 Rails3 和 Paperclip 的 NoHandlerError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我关于 StackOverflow 的第一个问题.

So this is my first question on StackOverflow.

我正在尝试在 Rails 3.2.3 上实现 Paperclip,在单击提交"以使用上传的图像创建配置文件后,我得到:

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

Paperclip::AdapterRegistry::NoHandlerError in UsersController#update

未找到Screen Shot 2012-09-01 at 11.03.43 AM.png"的处理程序

No handler found for "Screen Shot 2012-09-01 at 11.03.43 AM.png"

我的服务器日志读取,

Paperclip::AdapterRegistry::NoHandlerError(未找到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'

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'

无论我是否包含 S3 信息,错误仍然存​​在.在我的迁移过程中,

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

在我的 Gemfile 中,我有 gem "paperclip","~> 3.1.4"(更新:我已经直接从 Thoughtbot 中提取了 Paperclip,但问题仍然存在).我已经运行捆绑安装.我已经运行了 db:migrate.我已阅读 此 StackOverflow 条目,但无论我是否包含multipart => true"或不是.当我尝试了 艾默生拉基教程时,它发挥了作用他试图显示5.times ..."命令的输出.

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.

我对让 Paperclip 工作和了解NoHandlerError"是什么以及如何在未来避免它感兴趣.

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

推荐答案

您是否尝试过 Railscasts 第 134 集?

Did you try the railscasts episode # 134 ?

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

这篇关于使用 Rails3 和 Paperclip 的 NoHandlerError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆