Defect #8824

table name prefix and suffix are not used in some vendor plugins

Added by Tim marston almost 11 years ago.

Status:NewStart date:2011-07-15
Priority:NormalDue date:
Assignee:-% Done:


Category:Accounts / authentication
Target version:-
Resolution: Affected version:


Some plugins that create classes based on ActiveRecord::Base specify their own table names (with `set_table_name`), which overrides the default table name guessing mechanism. But they do not use `table_name_prefix` and `table_name_suffix` in their table names. So when these are set, the classes are unable to find their tables in the database.

To reproduce (an example):

1. Add `config.active_record.table_name_prefix = 'whatever_'` to `config/additional_environment.rb`.
2. Create/init database with this set
2. Enable OpenID from the administration settings page
3. Set an OpenID URL for your user and try to log in with OpenID

What happens:

- an error 500 is returned
- this is in the logs:
ActiveRecord::StatementInvalid (Mysql::Error: Table 'your_db_name.open_id_authentication_associations' doesn't exist: SHOW FIELDS FROM `open_id_authentication_associations`):
/usr/lib/ruby/gems/1.8/gems/ruby-openid-2.1.8/lib/openid/consumer/associationmanager.rb:116:in `get_association'

Here is the output from `RAILS_ENV=production ruby script/about`:

About your application's environment
Ruby version 1.8.7 (i486-linux)
RubyGems version 1.7.2
Rack version 1.1.2
Rails version 2.3.11
Active Record version 2.3.11
Active Resource version 2.3.11
Action Mailer version 2.3.11
Active Support version 2.3.11
Application root /home/edam/www/
Environment production
Database adapter mysql
Database schema version 20110511000000

I have attached a patch that fixes the following plugins:

- open_id_authentication
- classic_pagination
- awesome_nested_set

Disclaimer: please forgive me if I have misunderstood anything. This is the first time I've ever seen any ruby, let alone rails or redmine code!

patch.txt Magnifier (2.6 KB) Tim marston, 2011-07-15 13:10

Also available in: Atom PDF