custom table_name for table users with devise

oto iashvili
2013-03-07T14:06:17Z

Hi
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
  rolify
  # 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
    debugger
    ''franceusers''
  end

  def self.table_name_prefix
    debugger
    ''france''
  end

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 have
an error :

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


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 ?

thanks

merci

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/c73EBS7-PMoJ.
For more options, visit https://groups.google.com/groups/opt_out.