i am working on a project, in that project for every model we have two properties common
- Created_ts
- Created_by
I want to add a base class in which i want to set these properties, i tried using
class BaseModel < ActiveRecords::Base
end
class Person < BaseModel
end
when i create an instance of Person model it gives exception, i am not sure why it is giving exception, may be because it is looking for table BaseModels.
can any one please suggest, how to do this.
Exception :
PG::UndefinedTable: ERROR: relation "base_models" does not exist
LINE 5: WHERE a.attrelid = '"base_models"'::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 = '"base_models"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "base_models" does not exist
LINE 5: WHERE a.attrelid = '"base_models"'::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 = '"base_models"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum