omniauth / omniauth-identity

A simple login and password strategy for OmniAuth.
MIT License
345 stars 98 forks source link

Potential Problem with Rails 3.2 & ActiveRecord #15

Closed ahawkins closed 3 years ago

ahawkins commented 12 years ago

Here is my Identity model:

class Identity < OmniAuth::Identity::Models::ActiveRecord
  validates :name, :presence => true
  validates :email, :presence => true, :email => true
end

When trying to use the class, I get this lovely error from Postgres:

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

It seems through the combination of AR's abstract_class and inheritance something is going wrong. Adding a self.table_name = "identities" solves the problem though:

class Identity < OmniAuth::Identity::Models::ActiveRecord
  self.table_name = 'identities'

  validates :name, :presence => true
  validates :email, :presence => true, :email => true
end
apolzon commented 11 years ago

I'm using pg 0.14.1, omniauth-identity 1.1.0, rails 3.2.11 and not having this issue.

pboling commented 3 years ago

This is fixed.