Attachment_fu问题

发布于 2024-10-06 15:20:50 字数 341 浏览 9 评论 0原文

我正在尝试在 jRuby-1.5.2 和 Rails 3 上使用attachment_fu + 图像科学。我已遵循attachment_fu 文档。但是,当我从浏览器上传表单时,我在 validate_as_attachment 上收到错误消息,指出大小不能为空。这就是日志所说的

大小不能为空翻译缺失:en.activerecord.errors.messages.inclusion

当我修改插件以忘记大小检查或不添加 validate_as_attachment 检查时,会在数据库表中创建一个条目,但实际情况文件未传输。

任何人都可以指导我吗?还有可用的 Rails3 兼容插件吗?

感谢您的帮助

I am trying to use attachment_fu + image science on jRuby-1.5.2 and Rails 3. I have followed the attachment_fu docs. However, when I upload the form form the browser, i get an error on validate_as_attachment saying size cannot be blank. This is what the log says

size can't be blank translation missing: en.activerecord.errors.messages.inclusion

when I modify the plugin to forget size check or not add validate_as_attachment check, an entry is made in the DB table but the actual file is not transfered.

Can anyone please guide me, Also is there a Rails3 compatible plugin available.

Thanks for the help

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

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

发布评论

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

评论(3

拿命拼未来 2024-10-13 15:20:50

AttachmentFu 相当旧。我不知道它是否还在积极维护。

想到的替代方案是 PaperclipCarrierwave。回形针是较旧的,很好,但感觉有点过时。 Carrierwave 感觉与 Rails 3 更加同步,而且我听到了很多关于它的精彩内容。

AttachmentFu is rather old. I don't know if it's still being maintained actively.

The alternatives that pop into mind are Paperclip and Carrierwave. Paperclip is the older one, good, but feels a bit dated. Carrierwave feels more in sync with Rails 3 and I've been hearing a lot of great things about it.

如果没结果 2024-10-13 15:20:50

您需要在您的 config/locales/en.yml 文件中添加类似的内容

en:
  activerecord:
    errors:
      messages:
        inclusion: "Attachment"

You need to add to your config/locales/en.yml file something like

en:
  activerecord:
    errors:
      messages:
        inclusion: "Attachment"
病女 2024-10-13 15:20:50

我建议你将 Attachment_fu 更改为 gem,
如果您还没有这样做,请将其添加到您的 Gemfile 中:

git "https://github.com/pothoven/attachment_fu.git" do
  gem 'pothoven-attachment_fu'
end

因为我在此处提供的链接包含使其在 Rails 3 和 4 上工作的补丁。
当您遇到兼容性问题时,通常会出现此错误。

更新你的 Attachment_fu 后,请确保每当你实例化一个新图像时,你都会执行如下操作:

image = YourImageModel.new()
image.uploaded_data = image_data_here

如果你检查实现,签名已更改,这就是为什么你应该将图像模型的初始化更改为这样

I suggest you change your attachment_fu to be a gem,
if you haven't done it yet, add this on your Gemfile:

git "https://github.com/pothoven/attachment_fu.git" do
  gem 'pothoven-attachment_fu'
end

Because this version I'm providing the link here has the patch for making it work on rails 3 and 4.
This error you are getting happens normally when you have compatibility issues.

After updating your attachment_fu then make sure that, whenever you instantiate a new image you do something like this:

image = YourImageModel.new()
image.uploaded_data = image_data_here

If you check on the implementation, the signature has changed, that's why you should change the initializations of your image models to be like this

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