Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 基于版本的回形针文档URL生成_Ruby On Rails_Ruby On Rails 3_Paperclip - Fatal编程技术网

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)