环境:Rails 3.2.11
添加了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 :(得分:2)
您是否遵循了安装说明:
通过您的Gemfile将PaperTrail安装为gem:
gem'paper_trail','〜&gt; 2'
生成迁移,将版本表添加到数据库中。
bundle exec rails generate paper_trail:install
运行迁移。
bundle exec rake db:migrate
将has_paper_trail添加到要跟踪的模型中。