Q:

Define table name Ruby on Rails 3.2.1

I've got a legacy database that I'm connecting to via the sqlserver adapter.  One of the databases is called "SiteIndex_Players".  I've generated the following model:
class SiteIndexPlayer < ActiveRecord::Base
  set_table_name = "SiteIndex_Players"
end

I've also tried:
class SiteIndexPlayer < ActiveRecord::Base
  table_name = "SiteIndex_Players"
end

Both ways, when I run the rails console rails c, I get this:
1.9.2-p290 :001 > SiteIndexPlayer.first
SiteIndexPlayer Load (352.1ms)  EXEC sp_executesql N'SELECT TOP (1) [site_index_players].*    FROM [site_index_players]'
ActiveRecord::StatementInvalid: TinyTds::Error: Invalid object name 'site_index_players'.: EXEC sp_executesql N'SELECT TOP (1) [site_index_players].* FROM [site_index_players]'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-sqlserver-adapter-3.2.1/lib/active_record/connection_adapters/sqlserver/database_statements.rb:412:in `each'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-sqlserver-adapter-3.2.1/lib/active_record/connection_adapters/sqlserver/database_statements.rb:412:in `handle_to_names_and_values_dblib'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-sqlserver-adapter-3.2.1/lib/active_record/connection_adapters/sqlserver/database_statements.rb:401:in `handle_to_names_and_values'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-sqlserver-adapter-3.2.1/lib/active_record/connection_adapters/sqlserver/database_statements.rb:373:in `_raw_select'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-sqlserver-adapter-3.2.1/lib/active_record/connection_adapters/sqlserver/database_statements.rb:367:in `block in raw_select'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-sqlserver-adapter-3.2.1/lib/active_record/connection_adapters/sqlserver/database_statements.rb:367:in `raw_select'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-sqlserver-adapter-3.2.1/lib/active_record/connection_adapters/sqlserver/database_statements.rb:350:in `do_exec_query'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-sqlserver-adapter-3.2.1/lib/active_record/connection_adapters/sqlserver/database_statements.rb:24:in `exec_query'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-sqlserver-adapter-3.2.1/lib/active_record/connection_adapters/sqlserver/database_statements.rb:293:in `select'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:16:in `select_all'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/querying.rb:38:in `block in find_by_sql'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/explain.rb:40:in `logging_query_plan'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/querying.rb:37:in `find_by_sql'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/relation.rb:170:in `exec_queries'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/relation.rb:159:in `block in to_a'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/explain.rb:33:in `logging_query_plan'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/relation.rb:158:in `to_a'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/relation/finder_methods.rb:377:in `find_first'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/relation/finder_methods.rb:122:in `first'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.1/lib/active_record/querying.rb:5:in `first'
from (irb):1
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands/console.rb:47:in `start'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands/console.rb:8:in `start'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'1.9.2-p290 :002 > 

Makes sense, the table is "SiteIndex_Players", not "site_index_players" (notice the missing underscore).
Is there a way I can define the table to have the name "SiteIndex_Players"?
Thanks

A:

Instead of 
set_table_name = "SiteIndex_Players"
you need
set_table_name "SiteIndex_Players"
without the equals sign.
See: http://apidock.com/rails/ActiveRecord/Base/set_table_name/class

