我正在努力将Rails 2.3.11,Ruby 1.9.2应用程序升级到Rails 3.0.10,并且attachment_fu不再有效.
我正在寻找更改为paperclip,carrierwave或dragonfly的文件上传,或者可能是raails 3兼容,维护版本的attachment_fu.
哪些选项在性能方面最好用,维护得多好,从attachment_fu升级是多么容易,也许它会与Rails 3.1兼容?每个人的主要优点和缺点是什么?
任何见解将不胜感激.
attachment-fu paperclip ruby-on-rails-3 carrierwave dragonfly-gem
我一直在研究rails文件上传工具,对我来说最吸引人和最有趣的是carrierwave和dragonfly.
从环顾四周来看,似乎载波采用更传统的风格,您可以在保存时处理文件,而蜻蜓是中间件,因此它允许您即时处理.
我想知道人们是否有任何参考性能测试或任何比较两者的测试.
此外,只是好奇人们的意见是什么,他们喜欢什么,当然为什么他们喜欢它.
我只是另一个希望跳上社交网络潮流的普通乔.我想知道我应该为我的应用用户使用哪张照片上传/调整大小宝石.如果你能解释原因会很棒.
ruby-on-rails paperclip ruby-on-rails-3 carrierwave dragonfly-gem
我一直在寻找一些例子,但是很简单:
我正在尝试在我正在处理的项目上实现JQuery-File-Upload,但是我很想知道如何使用嵌套属性.
快速概述:
2型号:
Comment [has_many :attachments]
Attachment [belongs_to :comment]
Run Code Online (Sandbox Code Playgroud)
评论accepted_nested_attributes_for :attachments.另外 - 我正在使用Dragonfly.
我已经回顾了JQuery-File-Upload网站上的Rails 3指南,但是他们认为它是一个单一的模型,所以它都是围绕一个表单构建的.有没有人有任何他们的实现的例子,或者是否有一个我还没有偶然发现的现有教程?
我确定有人有类似的问题...是JQuery-File-Upload到适当的工具还是我应该看看其他什么?
我正在开发一个在本地工作良好的refinerycms rails应用程序,现在我已将它移动到我的VPS,我遇到的问题是我通过refinerycms上传的图像没有加载,我一直在阅读我需要升级我的imagemagick版本.我从6.2.8升级到6.7.8.现在图像都加载到某些页面上,但不在管理端加载.
是什么导致了这个问题?这是错误的堆栈跟踪.
Dragonfly::Shell::CommandFailed (Command failed (convert '/var/www/vhosts/tomstestsite.us/PersonalTrainingKT/public/system/refinery/images/2012/06/03/16_36_48_339_pamLemke_after.jpg' '-resize' '225x255>' '/tmp/dragonfly20120705-7812-1xb3pce') with exit status 127):
dragonfly (0.9.12) lib/dragonfly/shell.rb:29:in `raise_shell_command_failed'
dragonfly (0.9.12) lib/dragonfly/shell.rb:23:in `run'
dragonfly (0.9.12) lib/dragonfly/image_magick/utils.rb:17:in `convert'
dragonfly (0.9.12) lib/dragonfly/image_magick/processor.rb:103:in `convert'
dragonfly (0.9.12) lib/dragonfly/image_magick/processor.rb:27:in `resize'
dragonfly (0.9.12) lib/dragonfly/image_magick/processor.rb:87:in `thumb'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:39:in `call'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:39:in `block (2 levels) in call_last'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:38:in `catch'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:38:in `block in call_last'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:37:in `each'
dragonfly (0.9.12) lib/dragonfly/function_manager.rb:37:in `call_last'
dragonfly (0.9.12) lib/dragonfly/processor.rb:5:in `process'
dragonfly (0.9.12) lib/dragonfly/job.rb:79:in `apply'
dragonfly (0.9.12) lib/dragonfly/job.rb:253:in …Run Code Online (Sandbox Code Playgroud) 我正在使用Heroku上托管的Dragonfly和rack/cache的组合.
我正在使用Dragonfly上传资产.缩略图即时处理并存储在机架/缓存中,以便从memcached(通过Memcachier插件)快速传送.
常规静态资产也通过rack/cache缓存在memcached中.
我的问题是,任何超过1MB的上传文件都会导致我的应用程序出现500错误.
2013-07-15T10:38:27.040992+00:00 app[web.1]: DalliError: Value too large, memcached can only store 1048576 bytes per key [key: d49c36d5db74ef45e957cf169a0b27b83b9e84de, size: 1502314]
2013-07-15T10:38:27.052255+00:00 app[web.1]: cache: [GET /media/BAhbBlsHOgZmSSIdNTA3Njk3ZWFiODBmNDEwMDEzMDAzNjA4BjoGRVQ/WTW_A5Flyer_HealthcareMedicalObsGynae_WEB.pdf] miss, store
2013-07-15T10:38:27.060583+00:00 app[web.1]: !! Unexpected error while processing request: undefined method `each' for nil:NilClass
Run Code Online (Sandbox Code Playgroud)
Memcache的限制为1MB,所以我可以理解为什么我的资产没有被缓存,但我宁愿它不会破坏服务资产.
我甚至不确定这个错误来自哪里.大概来自其他机架中间件之一?
增加最大文件大小似乎没有任何影响.
config.cache_store = :dalli_store, ENV["MEMCACHIER_SERVERS"].split(","), {¬
:username => ENV["MEMCACHIER_USERNAME"],¬
:password => ENV["MEMCACHIER_PASSWORD"],¬
:value_max_bytes => 5242880 # 5MB¬
}
Run Code Online (Sandbox Code Playgroud)
从长远来看,我知道将这种资产从Heroku中移除是一个明智的举动,但这不会是一个快速的工作.
在此期间,我可以做什么来在Heroku上提供这些资产而不会出错?
我正在尝试使用rails3中的dragonfly进行多个图像上传.我搜索了一些教程,但找不到任何教程.我找到了一个用Carrierwave上传多个图像的教程,但是找不到运气蜻蜓..任何帮助请:)
使用Rails管理员和Dragonfly.但是,当我创建了一个新帖子,附件连接:ob到dragonfly并想要编辑它.这是"没有选择文件".因为它没有拿起已存在的文件?
在我的rails_admin中,我做到了这一点.
edit do
field :name
field :information
field :ob, :dragonfly
field :document_categories
end
Run Code Online (Sandbox Code Playgroud)
这是我的模特:
class Document < ActiveRecord::Base
has_and_belongs_to_many :document_categories
after_commit :generate_versions, on: :create
dragonfly_accessor :ob
validates :name, :ob, presence: true
def generate_versions
DocumentWorker.perform_async(self.id)
end
def convertable_image?
unless self.try(:ob).nil?
self.try(:ob).mime_type.include?("image") || self.try(:ob).mime_type.include?("pdf")
else
return false
end
end
def respond_with_type
case self.try(:ob).mime_type.split("/")[1]
when "vnd.ms-powerpoint" , "vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.template"
"powerpoint"
when "application/vnd.ms-excel" , "vnd.openxmlformats-officedocument.spreadsheetml.sheet"
"excel"
when "application/msword" , "vnd.openxmlformats-officedocument.wordprocessingml.document"
"word"
else
self.try(:ob).mime_type.split("/")[1]
end
end
default_scope{order("name ASC")} …Run Code Online (Sandbox Code Playgroud) 我正在使用Dragonfly处理Rails 3.1应用程序上的图像.我正在努力通过网址将图像分配给模型.
我有一个工作正常的形式:
<%= form_for [@word, @game, @picture], :html => {:multipart => true} do |f| %>
<%= f.hidden_field :retained_image %>
<p>
<%= f.label :image, "upload pic" %><br />
<%= f.file_field :image %>
</p>
<p>
<%= f.label :image_url, "or pic URL" %><br />
<%= f.text_field :image_url %>
</p>
<p>
<% if @picture.image_uid? %>
<label>Remove Picture?</label>
<%= f.check_box :remove_image %>
<% end %>
</p>
<p><%= f.submit %></p>
<% end %>
Run Code Online (Sandbox Code Playgroud)
Dragonfly的文档说明:
Dragonfly提供了一个直接从url分配的访问器:
@album.cover_image_url = 'http://some.url/file.jpg'
Run Code Online (Sandbox Code Playgroud)
但是当我在我的控制台中尝试时:
=> #<Picture id: nil, game_id: nil, …Run Code Online (Sandbox Code Playgroud) 假设我有这个图像:

我想将颜色数量减少到 3 种,如下所示:

为此,我应用了以下命令:
convert orange.jpg -remap palette.png orange_output.png
其中palette.png 看起来像这样:

有没有办法在不使用调色板图像的情况下执行此转换?理想情况下,我想提供一个颜色列表并让它以这种方式转换图像。
dragonfly-gem ×10
paperclip ×3
carrierwave ×2
file-upload ×2
ruby ×2
caching ×1
heroku ×1
image ×1
imagemagick ×1
memcached ×1
rails-admin ×1
refinerycms ×1
rmagick ×1
rubygems ×1