开发者

Attachment_fu issue

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


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.


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

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜