Forum: Ruby on Rails custom table_name for table users with devise

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
oto iashvili (Guest)
on 2013-03-07 15:07
(Received via mailing list)
for my app, I have several tables for users (franceusers, belgiumusers,
...) and I would like to use one or another depending on domain
I tried with table_name_prefix and table_name but it seems to not work

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, #:confirmable,
         :recoverable, :rememberable, :trackable, :validatable

  def self.table_name

  def self.table_name_prefix

thanks to debugger, I can see that is called but not
self.table_name_prefix. And even if self.table_name if called, devise
search users in tables users instead of franceusers

in console
User.table_name => "franceusers"
User.table_name_prefix => "france"

more weird, im also using activeadmin, and when I browse users list, I
an error :

Mysql2::Error: Unknown column '' in 'order clause': SELECT
`users`.* FROM `users`  ORDER BY `franceusers`.`id` desc LIMIT 30 OFFSET

it seems it can find table_prefix for field but not for FROM.

do I do anything bad ? is there another way to change users table name ?


This topic is locked and can not be replied to.