> After I played a little bit with the table definition in the DB using
> Microsoft SQL Server Mangement Studio Express I realized that the ID
> column, although primary key, was not set as IDENTITY column. I
> changed that and... nothing! Same error.
>
> Just for the fun of it I explicitly declared the primary key in my
> model:
>
>     class Contact < ActiveRecord::Base
>       self.primary_key = 'ID'
>     end
>
> That did the trick. It seems you have to specify the primary key or
> you won't be able to save the records.

I found the 'problem'. It was the case of the field names. All fields
in the table were either upper or mixed case, including ID. I renamed
the fields to all lowercase and removed the primary key declaration
from the model. I then tried again to create a new record and it went
through. I didn't try making the ID column NOT IDENTITY as I think the
table still needs it, though.

> And one last thing. My table has column names such as FirstName and
> LastName. ActiveRecord forced me to use case sensitive symbols during
> assignments:
>    I could use :FirstName => ...
>    I could not use :firstname or :firstName
>
> This last one might have to do with the DB or table definition but I
> have not had time to research it to see if making column names case
> insensitive is possible under SQL Server. The weird thing is that
> using the Management tool I tried to create a column named 'firstname'
> just to check and the tool didn't let me. ???

I looked everywhere I could around the DB Management tool and could
find nothing that would disregard the case of the column names. I also
looked up all methods names for ActiveRecord::Base and couldn't find
anything there either. If anybody knows how to set this up so the case
is disregarded I would appreciate the tip.

Thank you

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to