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" end Everything works fine. I can retrieve records without issue. However, when create a new instance of InventoryItem, there are no attributes returned! i = InventoryItem.new #<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! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/b109b3c6/attachment.html
Sorry, but what attributes are you expecting when creating brand new record using InventoryItem.new? On 3/25/06, Brian Hogan <bphogan@gmail.com> wrote:> > 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" > end > > Everything works fine. I can retrieve records without issue. > > However, when create a new instance of InventoryItem, there are no > attributes returned! > > i = InventoryItem.new > #<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! > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/aa7bc047/attachment.html
Well, generally, I''d have an attributes hash filled with the fields in my table. I have a column in the table called "computername" When I do i = InventoryItem.new i.computername = ''test'' I get a NoMethodException. It''s really strange. It happens with all of my other tables as well. On 3/24/06, Emin Hasanov <emin@hasanov.com> wrote:> > Sorry, but what attributes are you expecting when creating brand new > record using InventoryItem.new? > > On 3/25/06, Brian Hogan < bphogan@gmail.com> wrote: > > > 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" > end > > Everything works fine. I can retrieve records without issue. > > However, when create a new instance of InventoryItem, there are no > attributes returned! > > i = InventoryItem.new > #<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! > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060325/2cb8253a/attachment-0001.html
Brian Hogan wrote:> > Anyone know where I would start looking?Can you update an existing InventoryItem?
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 logic. Does the sequence field have meaing in rails? -- Posted via http://www.ruby-forum.com/.
Ugh. If I have to remove the underscores then there''s no way I can use Rails for this project. These are legacy tables for a third-party (purchased) system. As for updating, it appears to be working just fine. On 3/25/06, Paulie <pauliephonic@gmail.com> wrote:> > 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 > logic. > > Does the sequence field have meaing in rails? > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060325/c2788a15/attachment.html
I found my own solution to this problem. The square brackets that wrap the table name had to be removed. set_table_name "_SMDBA_._INVENTOR_" instead of set_table_name "[_SMDBA_].[_INVENTOR_]" Thanks for the suggestions. On 3/25/06, Brian Hogan <bphogan@gmail.com> wrote:> > Ugh. If I have to remove the underscores then there''s no way I can use > Rails for this project. These are legacy tables for a third-party > (purchased) system. > > As for updating, it appears to be working just fine. > > > > > On 3/25/06, Paulie <pauliephonic@gmail.com> wrote: > > > > 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 > > logic. > > > > Does the sequence field have meaing in rails? > > > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060327/0b16d81c/attachment.html