gpt4 book ai didi

ruby-on-rails-3 - 与工厂女孩一起使用回形针,没有图像处理程序错误

转载 作者:行者123 更新时间:2023-12-04 06:42:02 25 4
gpt4 key购买 nike

我正在尝试将回形针与 factory_girl gem 一起使用,但出现“找不到处理程序”
错误信息。

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

类别 Controller 测试文件:
require 'test_helper'

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

最佳答案

我让它在我的应用程序/工厂中使用以下代码:

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

关于ruby-on-rails-3 - 与工厂女孩一起使用回形针,没有图像处理程序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13627906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com