I have a pretty simlple model:
class SystemKnowledge < ActiveRecord::Base
validates_presence_of :system, :value
validates_numericality_of :value, only_integer: true, greater_than: 0, less_than_or_equal_to: 100
belongs_to :issue
attr_accessible :system, :value
end
Once I call model.destroy
on an object, I get this error:
ActiveRecord::StatementInvalid: TinyTds::Error: Incorrect syntax near '='.:
EXEC sp_executesql N'DELETE FROM [system_knowledge] WHERE [system_knowledge]. = @0;
SELECT @@ROWCOUNT AS` AffectedRows', N'@0 int', @0 = 275
As far as I get it, the problem is that there is no id
field in the generated SQL. What I don't get is why this is happening.
I'm using Rails 4.2 with SQL Express 2014 and TinyTds.
Any help will be greatly appreciated.
Turns out the problem was there was no primary key set up in the DB table. After adding the primary key explicitly to the table, it all began to work.