Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table name prefix & suffix not taken into account for active_admin_comments #5093

Closed
Techbrunch opened this issue Jul 22, 2017 · 0 comments
Closed

Comments

@Techbrunch
Copy link
Contributor

Techbrunch commented Jul 22, 2017

Because I'm currently working with a legacy database, I have setup a table name prefix in config/application.rb.

ActiveRecord::Base.table_name_prefix = 'prefix_'

It appears that ActiveAdmin does not pickup on that, which result in a Mysql error when trying to display the index page of the Comment resource or any individual resources:

Expected behavior

ActiveAdmin should detect that a prefix has been set on ActiveRecord and use it when retrieving admin comments.

Actual behavior

I think that since table_name is set /lib/active_admin/orm/active_record/comments/comment.rb the table_name_prefix is discarded.

ActiveRecord::StatementInvalid in Admin::CommentsController#index
Mysql2::Error: Table 'database.active_admin_comments' doesn't exist: SHOW FULL FIELDS FROM `active_admin_comments`

Suggested fix

Something like:

module ActiveAdmin
  class Comment < ActiveRecord::Base

    self.table_name = "#{self.table_name_prefix}active_admin_comments"
[...]

I'll see if this work tomorrow and if yes I'll create a pull request.

PS: Note same thing is happening for the suffix.

@Techbrunch Techbrunch changed the title table_name_prefix not taken into account for active_admin_comments table name prefix & suffix not taken into account for active_admin_comments Jul 23, 2017
Techbrunch pushed a commit to Techbrunch/activeadmin that referenced this issue Jul 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant