开发者

paperclip + vestal_versions problem

开发者 https://www.devze.com 2023-04-01 13:46 出处:网络
I need help to setup paperclip with vestal_versions. I followed this tutorial http://blog.dmfranc.com/post/1036667709/paperclip-and-vestal-versions

I need help to setup paperclip with vestal_versions. I followed this tutorial

http://blog.dmfranc.com/post/1036667709/paperclip-and-vestal-versions

But when i try to upload files, i get this error

[paperclip] Saving attachments. Completed 500 Internal Server Error in 626ms

NoMethodError (undefined method `version' for #):

my file model are a belongs_to from the buildings and building has_menu build开发者_运维技巧ing_pdf.

class BuildingPdf < ActiveRecord::Base
  belongs_to :building

  has_attached_file :pdf, :keep_old_files => true, :url => "/pdf/:id/versions/:version/:basename.:extension",
  :path => ":rails_root/system/pdf/:id/:version/:basename.:extension"

 Paperclip.interpolates :version do |attachment, style|
   attachment.instance.version.to_s
 end

end

here is my /lib/initializers/versioning_with_paperclip.rb

module Paperclip
  class Attachment
    def save
      flush_deletes unless @options[:keep_old_files]
      flush_writes
      @dirty = false
      true
    end
  end
end

what else i missing?

thanks.

PS. After i added versioning in my model i get this error

[paperclip] Saving attachments.
Completed 500 Internal Server Error in 1512ms

Mysql2::Error (Table 'db.versions' doesn't exist):
  app/models/building_pdf.rb:10:in `version'
  config/initializers/versioning_with_paperclip.rb:5:in `save'


You need to add (versioned) to your model

class BuildingPdf < ActiveRecord::Base
    versioned

    ..

end
0

精彩评论

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