I've loaded (and updated) thousands of these MeteredUsage records.  In
the middle of a run, I suddenly get:

ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'id' in
'where clause': UPDATE `metered_usages` SET `cost` = 12603.46 WHERE `id`
= NULL

I can't see anything that's different about this particular record
compared to its brethren.  (Note that I'm invoking this at the console
-- this is not a question about views or controllers.)  So the schema
and the model:
==========
  create_table "metered_usages", :id => false, :force => true do |t|
    t.integer "start_time_id"
    t.integer "end_time_id"
    t.integer "service_address_id"
    t.integer "metered_service_id"
    t.float   "quantity"
    t.float   "cost"
  end
==========
class MeteredUsage < ActiveRecord::Base
  belongs_to :start_time, :class_name => 'TimeDimension', :foreign_key
=> 'start_time_id'
  belongs_to :end_time, :class_name => 'TimeDimension', :foreign_key =>
'end_time_id'
  belongs_to :service_address
  belongs_to :metered_service
end
==========
Note that in this model, I'm inhibiting the generation of the id column
-- the uniqueness of a metered_usage is defined by its foreign keys.

The call that generated the error was an ActiveRecord#update():

        active_record.update_attributes(attributes)

where attributes (in this instance) were:

{:start_time_id=>10991, :end_time_id=>11021, :service_address_id=>46,
:metered_service_id=>97, :quantity=>"119700", :cost=>"12603.46"}

So the question is: why would ActiveRecord#update() generate SQL
referring to the non-existent id column?  And how do I make it stop?

- ff
-- 
Posted via http://www.ruby-forum.com/.

-- 
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