Attachment_fu 和 RMagick

发布于 2024-09-04 06:33:52 字数 1485 浏览 5 评论 0 原文

最终在我的 Mac 上安装 RMagick 后,我根据此处的教程设置了 Attachment_fu: http://clarkware.com/cgi/blosxom/2007/02/24#FileUploadFu&gt 当我尝试通过上传表单上传文件时,我收到大约 80 条消息,如下所示:

/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:44: warning: already initialized constant PercentGeometry
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:45: warning: already initialized constant AspectGeometry
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:46: warning: already initialized constant LessGeometry
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:47: warning: already initialized constant GreaterGeometry

我做了一些搜索并发现当您在应用程序中使用不同大小写的 require 语句两次要求 RMagick 时,可能会出现此问题: http://work.rowanhick.com/2007/12/19/require-rmagick-and-case-sensitivity/ 我自己不需要它,但我想也许我的environment.rb文件中的config.gem“rmagick”行可能需要它。

表单提交后,它给我一个验证错误:内容类型不包含在列表中 我已经检查了attachment_fu的来源,并在内容类型列表中找到了image/png,所以我不认为这是正确的错误消息:http://github.com/technoweenie/attachment_fu/blob/master/lib/technoweenie/attachment_fu.rb

有人对我如何让它发挥作用有任何想法吗?

After finally getting RMagick installed on my Mac I have set up attachment_fu according to the tutorial here: http://clarkware.com/cgi/blosxom/2007/02/24#FileUploadFu> when I try and upload a file via the upload form I get around 80 messages like these:

/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:44: warning: already initialized constant PercentGeometry
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:45: warning: already initialized constant AspectGeometry
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:46: warning: already initialized constant LessGeometry
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:47: warning: already initialized constant GreaterGeometry

I did some searching and found that this problem can arise when you require RMagick twice in an application using different casing for the require statement: http://work.rowanhick.com/2007/12/19/require-rmagick-and-case-sensitivity/ I am not requiring it myself, but I was thinking maybe with the config.gem "rmagick" line in my environment.rb file rails might be requiring it.

After the form submits it gives me a validation error of: Content type is not included in the list
I have checked the source for attachement_fu and found the image/png in the list of content types so I don't believe that is the proper error message: http://github.com/technoweenie/attachment_fu/blob/master/lib/technoweenie/attachment_fu.rb

Does anyone have any ideas on how I can get this to work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无法回应 2024-09-11 06:33:52

如果像我们一样,您使用的 gem(例如 gruff)需要如上所述的 rmagick(因此您无法真正纠正 require 语句的大小写),则可以配置捆绑器以使用匹配的大小写加载 rmagick。

例如,将以下内容添加到您的 Gemfile 中:

gem 'rmagick', '2.13.1', :require => 'RMagick'

今天让我们摆脱了困境。

感谢您的原始帖子 - 在阅读它之前我们都迷失了!

If, like us you're using a gem (such as gruff) which requires rmagick as above (and thus you can't really be correcting the case of the require statements), you can configure bundler to load rmagick using the matching case.

E.g. add the following to your Gemfile:

gem 'rmagick', '2.13.1', :require => 'RMagick'

That got us out of a real pickle today.

Thanks for the original post - we were lost until we read it!

把时间冻结 2024-09-11 06:33:52

Paperclip 也有类似的问题,通过从 environment.rb 中删除 config.gem 'rmagick' 行来解决。

Had a similar problem with Paperclip, solved by removing config.gem 'rmagick' line from environment.rb.

枫以 2024-09-11 06:33:52

更新:以下内容仅适用于 Mac。我的生产服务器对此感到窒息。不要使用它。

我也遇到过这个问题。在 config/environment.rb 中,我有:

config.gem 'rmagick'

并且它必须是小写,否则 Rails 认为我没有安装所需的 gem。

Attachment_fu 有一个名为 rmagick_processor.rb 的文件,其中包含以下行:

require 'RMagick'

如果将其更改为小写,“require 'rmagick'”,则 RMagick 错误消息消失。

Update: The following only works on the Mac. My production server choked on this. Don't use it.

I came across this problem as well. In config/environment.rb I've got:

config.gem 'rmagick'

And it has to be lowercase, otherwise Rails thinks I don't have the required gem installed.

Attachment_fu has a file called rmagick_processor.rb which has the line:

require 'RMagick'

If you change this to lowercase, "require 'rmagick'", the RMagick error messages disappear.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文