2013-07-16 55 views
1

Env:Rails 3.2.11papertrail「版本」不存在

添加了paper_trail gem。

請注意,我已經使用該寶石,我從來沒有遇到過問題,但這次我收到一個錯誤,我找不到原因。

在我的模型:

class User < ActiveRecord::Base 
    has_paper_trail :versions => :paper_trail_versions 
    ... 
end 

錯誤:

User Exists (0.6ms) SELECT 1 AS one FROM "users" WHERE ("users"."pseudo" = 'joel' AND "users"."id" != 21) LIMIT 1 
PG::Error: ERROR: relation "versions" does not exist 
LINE 5:    WHERE a.attrelid = '"versions"'::regclass 
             ^
:    SELECT a.attname, format_type(a.atttypid, a.atttypmod), 
        pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod 
       FROM pg_attribute a LEFT JOIN pg_attrdef d 
       ON a.attrelid = d.adrelid AND a.attnum = d.adnum 
      WHERE a.attrelid = '"versions"'::regclass 
       AND a.attnum > 0 AND NOT a.attisdropped 
      ORDER BY a.attnum 

    (0.1ms) ROLLBACK 
Completed 500 Internal Server Error in 28ms 

ActiveRecord::StatementInvalid (PG::Error: ERROR: relation "versions" does not exist 
LINE 5:    WHERE a.attrelid = '"versions"'::regclass 
             ^
:    SELECT a.attname, format_type(a.atttypid, a.atttypmod), 
        pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod 
       FROM pg_attribute a LEFT JOIN pg_attrdef d 
       ON a.attrelid = d.adrelid AND a.attnum = d.adnum 
      WHERE a.attrelid = '"versions"'::regclass 
       AND a.attnum > 0 AND NOT a.attisdropped 
      ORDER BY a.attnum 
) 

如何解決這個任何線索?

+0

我有同樣的錯誤:http://stackoverflow.com/questions/21714198/undefined-method-versions-for-page-translations –

回答

2

你有沒有按照安裝說明操作:

安裝PaperTrail爲通過您的Gemfile寶石:

寶石 'paper_trail', '〜> 2'

生成遷移,這將增加一個版本表到你的數據庫。

bundle exec rails generate paper_trail:install 

運行遷移。

bundle exec rake db:migrate 

將has_paper_trail添加到要跟蹤的模型。

https://github.com/airblade/paper_trail

+1

的人,我不認爲我沒有做那。我完全錯過了那一段。感謝您的回覆。這釘了它 – zabumba