Question

Env: Rails 3.2.11

Added paper_trail gem.

Note that I already used that gem and I never had a problem but this time I am getting an error and I can't find out why.

In my Model:

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

The error:

  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
)

any leads on how to troubleshoot this?

Was it helpful?

Solution

Have you followed the installation instructions:

Install PaperTrail as a gem via your Gemfile:

gem 'paper_trail', '~> 2'

Generate a migration which will add a versions table to your database.

bundle exec rails generate paper_trail:install

Run the migration.

bundle exec rake db:migrate

Add has_paper_trail to the models you want to track.

from https://github.com/airblade/paper_trail

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top