I followed the instructions found here to get my rails app to communicate with SQL Server on Ubuntu 10.04
All the tests documented there have passes except the when I try script/sconsole
I was able to make a db connection in irb
In my app I have a model Report.rb
class Report < ActiveRecord::Base
set_table_name "dbo.tvAllWorkstreams_Summary_AllReports_Sel"
end
in script/console I get the following
>>Report.count
NameError: uninitialized constant Report
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:443:in `load_missing_constant'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:92:in `const_missing'
from (irb):1
Here is my configuration:
Connecting to MS SQL Server 2000
database.yml
development:
adapter: sqlserver
mode: odbc
dsn: production
username: xxxx
password: xxxx
in environment.rb I added
config.gem ‘activerecord-sqlserver-adapter’, :version => ‘2.3.8’
* LOCAL GEMS *
actionmailer (2.3.8)
actionpack (2.3.8)
activerecord (2.3.8)
activerecord-sqlserver-adapter (2.3.8)
activeresource (2.3.8)
activesupport (2.3.8)
rack (1.1.0)
rails (2.3.8)
rake (0.8.7)
sqlite3-ruby (1.3.0)
what am I missing?
I don’t think this error has anything to do with the SqlServer adapter, for those you will get cannot find odbc errors or unable to connect to the data source. It is not seeing the report model here. Is the report model in
app/models/report.rb? I have this when I am namespacing and forget to put the namespace before the model name which would be.