C
Chris Gallagher
Hi,
Im currently writing a ruby script that will connect to a database using
active record and then insert data that has been scraped from certain
websites.
A problem that I have run into is that when i try to use the .save
command i receive the following error:
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract_adapter.rb:
': Mysql::Error: Unknown column 'id' in 'where clause': UPDATE results
SET `module_name` = '--- !ruby/object:
\nentity_filter: \nnormalized: \nparent: \nraw: true\nstring:
henry-mobile-server\nunnormalized: \n', `build
tp://10.37.150.55:8080', `build_status_since` = '12:42', `build_number`
= 'build.16', `last_failure` = NULL,
ss` = '20/11/06' WHERE id = NULL (ActiveRecord::StatementInvalid)
This is clearly due to the fact that I dont have any id fields in my
database as i thought that active record would do something similar to
rails and that i wouldnt have to define them? Obviously this isnt quite
the case?
the code that im using for this segment of the script is as follows:
Result.find
all,:conditions => ["build_url = ?",
records.build_url]).each do |b|
puts b.id
b.build_status_since = build_status_since
b.save
end
Is there a work around for this problem or am I missing the problem
completely here?
Cheers,
Chris
Im currently writing a ruby script that will connect to a database using
active record and then insert data that has been scraped from certain
websites.
A problem that I have run into is that when i try to use the .save
command i receive the following error:
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract_adapter.rb:
': Mysql::Error: Unknown column 'id' in 'where clause': UPDATE results
SET `module_name` = '--- !ruby/object:
\nentity_filter: \nnormalized: \nparent: \nraw: true\nstring:
henry-mobile-server\nunnormalized: \n', `build
tp://10.37.150.55:8080', `build_status_since` = '12:42', `build_number`
= 'build.16', `last_failure` = NULL,
ss` = '20/11/06' WHERE id = NULL (ActiveRecord::StatementInvalid)
This is clearly due to the fact that I dont have any id fields in my
database as i thought that active record would do something similar to
rails and that i wouldnt have to define them? Obviously this isnt quite
the case?
the code that im using for this segment of the script is as follows:
Result.find
records.build_url]).each do |b|
puts b.id
b.build_status_since = build_status_since
b.save
end
Is there a work around for this problem or am I missing the problem
completely here?
Cheers,
Chris