- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
目标 => 让多文件 uploader 工作。
当我尝试安装 uploader 时出现以下错误。
4.1.7@2.1.3 (Message)> mount_uploaders :attachments, AttachmentUploader
NoMethodError: undefined method `mount_uploaders' for #<Class:0x007fc17b4cc658>
from /Users/mm/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.7/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
如果我删除上传者末尾的 s
,我会得到:
4.1.7@2.1.3 (Message)> mount_uploader :attachments, AttachmentUploader
=> :serializable_hash
基于此,我认为我应该确认类(class)是正确的。这是我能做的:
4.1.7@2.1.3 (Message)> AttachmentUploader
=> AttachmentUploader < CarrierWave::Uploader::Base
我的模型是:
class Message < ActiveRecord::Base
belongs_to :user
belongs_to :conversation
delegate :list, to: :conversation, allow_nil: true
mount_uploaders :attachments, AttachmentUploader
end
我的 AttachmentUploader
类是:
class AttachmentUploader < CarrierWave::Uploader::Base
storage :file
end
在数据库中,我的 messages
表是:
create_table "messages", force: true do |t|
t.integer "user_id"
t.integer "conversation_id"
t.datetime "created_at"
t.datetime "updated_at"
t.text "payload"
t.hstore "headers", default: {}, null: false
t.hstore "to", default: [], array: true
t.hstore "from", default: {}, null: false
t.string "subject"
t.hstore "cc", default: [], array: true
t.text "body"
t.text "raw_body"
t.text "raw_html"
t.json "attachments"
end
基于此,我不明白为什么它没有加载,因为我已按照此处的自述文件中的说明进行操作 - https://github.com/carrierwaveuploader/carrierwave#multiple-file-uploads
如果我启动 rspec,这是一个完整的堆栈跟踪:
➜ GroupMailer git:(add_attachments) ✗ rspec
Coverage report generated for RSpec to /Users/matthewbarram/projects/GroupMailer/coverage. 48 / 100 LOC (48.0%) covered.
/Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.7/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined method `mount_uploaders' for #<Class:0x007f9269adfae0> (NoMethodError)
from /Users/matthewbarram/projects/GroupMailer/app/models/message.rb:5:in `<class:Message>'
from /Users/matthewbarram/projects/GroupMailer/app/models/message.rb:1:in `<top (required)>'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `require'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `require'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:348:in `require_or_load'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:480:in `load_missing_constant'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:180:in `const_missing'
from /Users/matthewbarram/projects/GroupMailer/spec/models/message_spec.rb:3:in `<top (required)>'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `load'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `block in load'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `load'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
from /Users/matthewbarram/.rbenv/versions/2.1.3/bin/rspec:23:in `load'
from /Users/matthewbarram/.rbenv/versions/2.1.3/bin/rspec:23:in `<main>'
任何帮助都会很棒!我已经坚持了几个小时。 :-)
谢谢!
最佳答案
原来问题是 gem 中不存在该方法。
我重新安装了 gem 但没有成功。然后我手动引用github master分支,重新安装就可以了。
关于ruby-on-rails - Carrierwave - 未定义方法 `mount_uploaders',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27455338/
我正在通过 Carrierwave 上传的裁剪图像的能力。这里是 RailsCast video on Youtube我正在关注的。 但是在上传器中包含 RMagick 后,我收到了: undefin
我正在尝试下载这个 image使用 CarrierWave 但它一直给出此异常: CarrierWave::IntegrityError 我的下载适用于许多图像,但不适用于该特定域。 我看过这个doc
我正在寻找在 Heroku 上的 Rails 应用程序中上传文件的最佳方式。设置:Rails 3、Carrierwave、Heroku、Mongoid 问题:偶尔,当用户上传不同大小的文件时,图像会保
嗨我只是无法找出我的代码有什么问题。我有两个模型 Items 和 Images 以及它们之间的关系 class Item :destroy accepts_nested_attributes_
我实际上是在 Railscast 383 中编写项目- 第二部分,当照片直接上传到 AWS S3 时,然后由 Sidekiq 在后台处理照片以创建照片的缩略图版本。我在 Rails 4 上。 我的问题
我正在尝试使用 Carrierwave 通过 Rails 应用程序将 Logo 图像上传到 Amazon s3 存储桶。但我的文件上传没有将文件读取为 HTTP 文件,并将 NULL 添加到数据库中。
问题是在 mongoids save! 操作中抛出的以下错误。 Mongoid::Errors::Validations: Validation failed - Img failed to be p
我试图在我的 Rails 3.2 应用程序中显示默认图像。我已按照 Carrierwave github 页面上的说明进行操作,并浏览了几篇 Stackoverflow 帖子。但是,出于某种原因,它仍
模型带有图像的远程 url,这意味着它不是在 Rails 中创建的 db 条目。然后第一次从Rails中的DB中获取我想检测图像尚未上传,为图像url分配remote_seed_url并保存!触发 C
Carrierwave 运行良好,我将目录移出公众(出于安全原因),当我尝试上传图像时出现此错误: Errno::EACCES in PostsController#create Permission
我正在使用carrierwave,但遇到了这个问题: 假设一旦项目交付,您需要添加一个部分,其中系统中的图像需要以不同的尺寸显示。我不想为系统中已有的每个图像重新生成新维度。我希望能够在 View 需
是否可以让 CarrierWave 在数据库中存储上传文件的完整路径,而不仅仅是文件名,并在每次访问时重新生成它们? 我希望这样做的原因是能够更改我存储文件的结构,而不会在已上传的文件移动到新位置之前
我正在使用来自主分支和 PostgreSQL 的多个文件上传 我的产品模型有一个名为“images”的字符串字段,我可以很好地附加多个图像。 但是我不知道的是,如何从产品中删除一张图片? 我可以删除文
我有一个允许的文件扩展名列表 def extension_white_list %w(pdf doc docx xls xlsx html tif gif jpg jpeg png bmp rtf
所以,我有一个购物车类,我一直保存在 session 中,直到购买完成,我需要能够在购买完成后将文件上传到购物车(不要问为什么,说来话长),我将所有这些信息转储到一个保存在数据库中的类中。 我经常使用
我正在使用carrierwave 和rmagick 来处理我的图片上传。我现在向 image_uploader.eb 添加了一个新版本(smallthumb): class ImageUploader
我知道我在这里错过了一些非常简单的东西...... CarrierWave::Storage::Fog::File有一个方法 exists ? 我如何使用它?我只是想检查远程存储上是否存在以前上传的文
我正在使用乘客和 capistrano 部署我的第一个 rails 应用程序。 一切都很好,直到我尝试在浏览器中启动应用程序时遇到此错误。 Error message: uninitialize
我有一个使用 CarrierWave gem 的 rails 3 应用程序。到目前为止,我已经上传了 48*48 和 100*100 的图片,但现在我想将它们存储在 200*200 中。 有没有办法调
我有两个模型,每个模型都有自己的 Carrierwave 上传器: class User < ActiveRecord::Base mount_uploader :avatar, AvatarUp
我是一名优秀的程序员,十分优秀!