collectiveidea / audited

Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.
MIT License
3.39k stars 686 forks source link

Queries are not appending the database prefix #222

Open jsanroman opened 9 years ago

jsanroman commented 9 years ago

When I configure _active_record.table_nameprefix="prefix" on a rails3 project (activerecord/mysql), this error is generated:

ActiveRecord::StatementInvalid (Mysql2::Error: Table 'database.audits' doesn't exist: SHOW FULL FIELDS FROM audits):

The queries are not appending the tables prefix. Can I force audits table name?

d4be4st commented 5 years ago

Found where the issue lies

https://github.com/collectiveidea/audited/blob/master/lib/audited/auditor.rb#L416

if module of a namespaced model is not loaded beforehand this line calculates the table_name and caches it.

We use a workaround where we use require_dependency 'module' on all namespaced models