有谁能让 Attachment_fu 与 Rails 3 一起使用吗?
我有一个 Rails 应用程序,正在从 Rails 2.3.5 升级到 Rails 3。它使用 Attachment_fu 进行文件上传。我们试图在不更改数据库的情况下进行此转换,因此我想避免此时更改为回形针或载波。
有人成功地将 Attachment_fu 与 Rails 3 和 Ruby 1.9.2 一起使用吗?我们使用的是最新版本的attachment_fu,声称适用于rails 3和ruby 1.9.2,但在任何包含文件上传的表单上都会收到“TypeError(无法将 nil 转换为整数):”。
之前问题的所有答案似乎都是“只需切换到回形针或载波”,如下所示: Attachment_fu 或 Paperclip for Rails3 或者 TypeError(无法将 nil 转换为 Integer):
谢谢!
I have a rails application that is being upgraded from Rails 2.3.5 to Rails 3. It uses attachment_fu for file uploads. We're trying to do this conversion without making DB changes, so I'd like to avoid changing to paperclip or carrierwave at this time.
Has anyone succeeded in using attachment_fu with Rails 3 and Ruby 1.9.2? We're using the most recent version of attachment_fu that claims to be ok for rails 3 and ruby 1.9.2, but getting 'TypeError (can't convert nil into Integer):' on any forms that include a file upload.
All the answers to previous questions seem to be 'just switch to paperclip or carrierwave' as in:
Attachment_fu or Paperclip for Rails3
or
TypeError (can't convert nil into Integer):
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我进行了以下更改,并且有效
attachment_fu.rb
我还将
returning filename.strip do |name|
更改为filename.strip.tap do |name|< /code>
init.rb
我在 github 上做了一个分支并进行了这些更改
https://github.com/debprado/attachment_fu
I made the following changes and it worked
attachment_fu.rb
I also changed
returning filename.strip do |name|
tofilename.strip.tap do |name|
init.rb
I made a fork on github with this changes
https://github.com/debprado/attachment_fu
Attachment_fu 修补 attachment_fu/init.rb 中的 Tempfile.make_tmpname,它在 1.9.2 中不起作用: sprintf("%d",nil) 失败,在 1.8.7 中此结果表达式为“0”。
解决方法是在 init.rb 中插入一行 from:
to
您可以在此处找到一些讨论 https://github.com/technoweenie/attachment_fu/issues/25
干杯!
attachment_fu patches Tempfile.make_tmpname in attachment_fu/init.rb, and it doesn't work in 1.9.2: sprintf("%d",nil) fails, and in 1.8.7 the result of this expression is "0".
The fix is to insert a line in init.rb from:
to
You can find some of the discussion here https://github.com/technoweenie/attachment_fu/issues/25
Cheers!
尝试我支持 Rails 3.2 的 gemified 版本:
https://rubygems.org/gems/pothoven-attachment_fu
Try my gemified version that supports Rails 3.2:
https://rubygems.org/gems/pothoven-attachment_fu