Forum: Ruby on Rails Microsoft SQL Server has me stumped

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.
Brian H. (Guest)
on 2006-03-24 23:18
(Received via mailing list)
I'm tinkering around with an old legacy table in SQL Server 2000.
Ruby 1.8.4, most recent ADO.rb file from RubyForge, Rails 1.0

 Here's the model:

class InventoryItem < ActiveRecord::Base
  set_table_name  "[_SMDBA_].[_INVENTOR_]"
  set_primary_key  "sequence"

Everything works fine. I can retrieve records without issue.

However, when create a new instance of InventoryItem, there are no
attributes returned!

i =
#<InventoryItem:0x365eee0 @new_record=true, @attributes={}>

Anyone know where I would start looking?

Seems strange then that InventoryItem.find(:first) would return a full
attribute set with all of the data appropriately assigned....

Thanks in advance!
Emin H. (Guest)
on 2006-03-25 00:16
(Received via mailing list)
Sorry, but what attributes are you expecting when creating brand new
Brian H. (Guest)
on 2006-03-25 06:45
(Received via mailing list)
Well, generally, I'd have an attributes hash filled with the fields in
I have a column in the table called "computername"
When I do

i =
i.computername = 'test'

I get a NoMethodException.

It's really strange. It happens with all of my other tables as well.
Ray B. (Guest)
on 2006-03-25 11:16
(Received via mailing list)
Brian H. wrote:

>     Anyone know where I would start looking?

Can you update an existing InventoryItem?
Paulie (Guest)
on 2006-03-25 13:34
Have you tried making a copy of the table without the underscore
characters and see if that works?

Just thinking that the underscores have meaning and may be clouding the

Does the sequence field have meaing in rails?
Brian H. (Guest)
on 2006-03-25 20:04
(Received via mailing list)
Ugh. If I have to remove the underscores then there's no way I can use
for this project. These are legacy tables for a third-party (purchased)

As for updating, it appears to be working just fine.
Brian H. (Guest)
on 2006-03-27 20:51
(Received via mailing list)
I found my own solution to this problem. The square  brackets that wrap
table name had to be removed.

set_table_name  "_SMDBA_._INVENTOR_"

instead of
set_table_name  "[_SMDBA_].[_INVENTOR_]"

Thanks for the suggestions.
This topic is locked and can not be replied to.