Using Existing Database - Model has no column

16 views
Skip to first unread message

Rad Ical

unread,
Apr 5, 2016, 3:30:30 AM4/5/16
to rubyonra...@googlegroups.com
I'm developing a new rails project using an existing SQL SERVER 2008
database.

rails 4.1.2
tiny_tds
activerecord-sqlserver-adapater 4.1.2

my model is

class IpProject < ActiveRecord::Base
self.table_name = 'IP_Projects'
self.primary_key = "ProjectID"
end

I know I can connect to the database because I get a result when I try
to get count of all data.

IpProject.count

but I can't retrieve data as it has no column

IpProject.columns returns []


I get results using ActiveRecords
ActiveRecord::Base.connection.exec_query("SELECT * FROM ip_projects")

I also get result using tiny_tds
client.execute("SELECT * FROM ip_projects")

Also, getting result using the model this way
IpProject.connection.exec_query("SELECT * FROM ip_projects").first


but using the model
IpProject.first
returns #<IpProject:0xab01c98> which has no columns or data

Am I missing something here?

--
Posted via http://www.ruby-forum.com/.
Reply all
Reply to author
Forward
0 new messages