Ruby on rails 基于版本的回形针文档URL生成
我正在尝试在我的应用程序中实现文件版本控制。我的应用程序中有以下模型Ruby on rails 基于版本的回形针文档URL生成,ruby-on-rails,ruby-on-rails-3,paperclip,Ruby On Rails,Ruby On Rails 3,Paperclip,我正在尝试在我的应用程序中实现文件版本控制。我的应用程序中有以下模型 class Document < ActiveRecord::Base versioned attr_accessible :name,:file,:attachable_type,:attachable_id belongs_to :user belongs_to :attachable , :polymorphic => true has_attache
class Document < ActiveRecord::Base
versioned
attr_accessible :name,:file,:attachable_type,:attachable_id
belongs_to :user
belongs_to :attachable , :polymorphic => true
has_attached_file :file, :preserve_files => true
Paperclip.interpolates :version do |attachment, style|
attachment.instance.version.to_s
end
end
如果我使用
document.file.url
我能够获得最新文件的路径。如何获取文件特定版本的url路径?
我尝试将version作为参数传递给url方法,但它似乎不起作用
document.file.url(:original, :version => 2)
非常感谢您的帮助。您提供了什么?我使用了一个文档版本模型来表示一个版本。
document.file.url(:original, :version => 2)