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

doesn't appear to respect config.active_record.table_name_prefix #328

Closed
joshdaloewen opened this issue Oct 4, 2012 · 4 comments
Closed

Comments

@joshdaloewen
Copy link

I've got a rails 3 app that sets config.active_record.table_name_prefix. The migration correctly creates myprefix_friendly_id_slugs, but any operations that would edit that table give errors like:

PGError: ERROR: relation "friendly_id_slugs" does not exist

Which makes me think that the table name is hard-coded. Is there a friendly_id config that allows us to change the table name?

@joshdaloewen
Copy link
Author

Well, I poked around the friendly_id code and answered my own question. Although friendly_id doesn't automatically respect the table prefix, it's easy enough to configure the new table name in the environment config file.

in /environments/production.rb

config.active_record.table_name_prefix = 'myprefix_'
FriendlyId::Slug.table_name = 'myprefix_friendly_id_slugs'

@norman
Copy link
Owner

norman commented Oct 5, 2012

Thanks for reporting this. I would definitely consider this a bug, and worth fixing.

@joshdaloewen
Copy link
Author

Cool. If I knew more about gits and forks and pushes and pulls I'd try fixing it myself...but I'm a bit of a noob

@dpmccabe
Copy link

In case anyone else is having this problem, you need only set FriendlyId::Slug.table_name = 'whatever_friendly_id_slugs' in an initializer somewhere. I'm using FriendlyId in a gem with namespaced models, so I had to prefix the table name with the name of my gem.

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

Successfully merging a pull request may close this issue.

3 participants