Hi,
I’m having some issues trying to run .find_by_sql against a Win MSSQL
2008
server. When I use the tiny_tds gem the query works without any issues.
require ‘rubygems’
gem ‘tiny_tds’, ‘= 0.6.2’
require ‘tiny_tds’
gem ‘activerecord’, ‘= 3.2.12’
require ‘active_record’
require ‘activerecord-sqlserver-adapter’
client = TinyTds::Client.new(:username => ‘user’,:password =>
‘pass’,:host
=> ‘host’,:database => ‘db’)
result = client.execute(sql)
=> #TinyTds::Result:0x000000022c3e48
When I try the same query with an ActiveRecord::Base model I don’t see
any
results (I’ve tried both :host and :dataserver with the same result).
class Ipdb < ActiveRecord::Base
establish_connection(
:adapter => “sqlserver”,
:host => ‘host’,
:username => ‘user’,
:password => ‘pass’,
:database => ‘db’,
)
self.table_name = “View_All_IPs”
end
ai = Ipdb.find_by_sql(sql)
p ai.size
=> 1
p ai.inspect
=>"[#]"
p ai[0].class
=> Ipdb()
p ai[0]
=> #
Any ideas about where the problem may be?
Thanks
J-H Johansen