Forum: Ruby on Rails Using Existing Database - Model has no column

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Rad I. (Guest)
on 2016-04-05 11:29
I'm developing a new rails project using an existing SQL SERVER 2008

rails 4.1.2
activerecord-sqlserver-adapater 4.1.2

my model is

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

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


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
returns #<IpProject:0xab01c98> which has no columns or data

Am I missing something here?
This topic is locked and can not be replied to.