加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails-3 – 使用带有工厂女孩的回形针,没有图像处理程序

发布时间:2020-12-16 19:14:14 所属栏目:百科 来源:网络整理
导读:我正在尝试使用带有factory_girl gem的paperclip但是找到了“没有找到处理程序 错误信息. test_should_update_category(CategoriesControllerTest): Paperclip::AdapterRegistry::NoHandlerError: No handler found for “/system/categories/images/000/000
我正在尝试使用带有factory_girl gem的paperclip但是找到了“没有找到处理程序
错误信息.

test_should_update_category(CategoriesControllerTest):
Paperclip::AdapterRegistry::NoHandlerError: No handler found for “/system/categories/images/000/000/001/original/tel1.JPG?1354197869”

工厂女孩档案:

FactoryGirl.define do
factory :category do
name "MyString"
description "MyText"
image { File.new(File.join(Rails.root,'test','tel1.JPG')) }
end
end

类别迁移:: —————

class CreateCategories < ActiveRecord::Migration
def up
create_table :categories do |t|
t.string :name
t.text :description
t.string :image

  t.timestamps
end
add_attachment :categories,:image
end

模型:

class Category < ActiveRecord::Base
attr_accessible :description,:image,:name
has_attached_file :image,:styles => { :thumb => "100x100>" }

end

类别控制器测试文件:

require 'test_helper'

class CategoriesControllerTest < ActionController::TestCase
setup do
@category = FactoryGirl.create(:category)
end

解决方法

我在我的app / factory中使用以下代码:
FactoryGirl.define do
  factory :upload do
    permalink "unique"
    upload Rack::Test::UploadedFile.new(Rails.root + 'spec/files/uploads/unique.jpg','image/jpg')
  end  
end

因此,在您的应用中,您应该将类??别的工厂更改为以下内容:

FactoryGirl.define do
  factory :category do
    name "MyString"
    description "MyText"
    image Rack::Test::UploadedFile.new(Rails.root +'test/tel1.JPG','image/jpg')
  end
end

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读