I''m receiving the following error .... ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: id: UPDATE user_jobs SET user_id = NULL WHERE (user_id = 1 AND id IN (NULL)) while trying to delete from a join table. Here''s the sequence from the console ....>> u = User.find(1)=> #<User:0xb70bc810 @attributes={"name"=>"Anthony", "id"=>"1"}>>> j= Job.find(4)=> #<Job:0xb70aa8f4 @attributes={"title"=>"Farmer", "id"=>"4"}>>> u.jobs << j=> [#<Job:0xb70aa8f4 @attributes={"title"=>"Farmer", "id"=>"4"}>]>> u=> #<User:0xb70bc810 @user_jobs=[#<UserJob:0xb7098ec4 @attributes={"job_id"=>"4", "user_id"=>"1"}>, #<UserJob:0xb709e7d4 @new_record=false, @attributes={"job_id"=>4, "id"=>1, "user_id"=>1}, @errors=#<ActiveRecord::Errors:0xb709c560 @base=#<UserJob:0xb709e7d4 ...>, @errors={}>>], @attributes={"name"=>"Anthony", "id"=>"1"}, @jobs=[#<Job:0xb70aa8f4 @attributes={"title"=>"Farmer", "id"=>"4"}>]>>> dj = u.jobs.find(4)=> #<Job:0xb7095c60 @attributes={"title"=>"Farmer", "id"=>"4"}>>> u.jobs.delete(dj)Here are my classes class Job < ActiveRecord::Base has_many :user_jobs has_many :users, :through => :user_jobs end class User < ActiveRecord::Base has_many :user_jobs has_many :jobs, :through => :user_jobs end class UserJob < ActiveRecord::Base belongs_to :job belongs_to :user end Here is my schema CREATE TABLE jobs ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL ); CREATE TABLE user_jobs ( user_id INTEGER NOT NULL, job_id INTEGER NOT NULL, PRIMARY KEY(user_id,job_id) ); CREATE TABLE users ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL ); rails 1.2.4 fron ubuntu. Any pointers would be great. thx -ants Disclaimer: Technically, I''m always wrong!! --------------------------------- Support the World Aids Awareness campaign this month with Yahoo! for Good --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Solved. Removed ubuntu''s rails and installed 2.0.2 using gems. Everything works as it should. Anthony Gardner <cyclewood_ltd-/E1597aS9LT10XsdtD+oqA@public.gmane.org> wrote: I''m receiving the following error .... ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: id: UPDATE user_jobs SET user_id = NULL WHERE (user_id = 1 AND id IN (NULL)) while trying to delete from a join table. Here''s the sequence from the console ....>> u = User.find(1)=> #<User:0xb70bc810 @attributes={"name"=>"Anthony", "id"=>"1"}>>> j= Job.find(4)=> #<Job:0xb70aa8f4 @attributes={"title"=>"Farmer", "id"=>"4"}>>> u.jobs << j=> [#<Job:0xb70aa8f4 @attributes={"title"=>"Farmer", "id"=>"4"}>]>> u=> #<User:0xb70bc810 @user_jobs=[#<UserJob:0xb7098ec4 @attributes={"job_id"=>"4", "user_id"=>"1"}>, #<UserJob:0xb709e7d4 @new_record=false, @attributes={"job_id"=>4, "id"=>1, "user_id"=>1}, @errors=#<ActiveRecord::Errors:0xb709c560 @base=#<UserJob:0xb709e7d4 ...>, @errors={}>>], @attributes={"name"=>"Anthony", "id"=>"1"}, @jobs=[#<Job:0xb70aa8f4 @attributes={"title"=>"Farmer", "id"=>"4"}>]>>> dj = u.jobs.find(4)=> #<Job:0xb7095c60 @attributes={"title"=>"Farmer", "id"=>"4"}>>> u.jobs.delete(dj)Here are my classes class Job < ActiveRecord::Base has_many :user_jobs has_many :users, :through => :user_jobs end class User < ActiveRecord::Base has_many :user_jobs has_many :jobs, :through => :user_jobs end class UserJob < ActiveRecord::Base belongs_to :job belongs_to :user end Here is my schema CREATE TABLE jobs ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL ); CREATE TABLE user_jobs ( user_id INTEGER NOT NULL, job_id INTEGER NOT NULL, PRIMARY KEY(user_id,job_id) ); CREATE TABLE users ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL ); rails 1.2.4 fron ubuntu. Any pointers would be great. thx -ants Disclaimer: Technically, I''m always wrong!! --------------------------------- Support the World Aids Awareness campaign this month with Yahoo! for Good Disclaimer: Technically, I''m always wrong!! --------------------------------- Sent from Yahoo! - a smarter inbox. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 19 Jan 2008, at 18:25, Anthony Gardner wrote:> Solved. Removed ubuntu''s rails and installed 2.0.2 using gems. > Everything works as it should. >That may be the case, but this will probably popup later on: with has_many :through, UserJob is a genuine model so should have a primary_key. Fred> Anthony Gardner <cyclewood_ltd-/E1597aS9LT10XsdtD+oqA@public.gmane.org> wrote: I''m receiving the > following error .... > > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such > column: id: UPDATE user_jobs SET user_id = NULL WHERE (user_id = 1 > AND id IN (NULL)) > > while trying to delete from a join table. Here''s the sequence from > the console .... > > >> u = User.find(1) > => #<User:0xb70bc810 @attributes={"name"=>"Anthony", "id"=>"1"}> > >> j= Job.find(4) > => #<Job:0xb70aa8f4 @attributes={"title"=>"Farmer", "id"=>"4"}> > >> u.jobs << j > => [#<Job:0xb70aa8f4 @attributes={"title"=>"Farmer", "id"=>"4"}>] > >> u > => #<User:0xb70bc810 @user_jobs=[#<UserJob:0xb7098ec4 > @attributes={"job_id"=>"4", "user_id"=>"1"}>, #<UserJob:0xb709e7d4 > @new_record=false, @attributes={"job_id"=>4, "id"=>1, "user_id"=>1}, > @errors=#<ActiveRecord::Errors:0xb709c560 @base=#<UserJob: > 0xb709e7d4 ...>, @errors={}>>], @attributes={"name"=>"Anthony", > "id"=>"1"}, @jobs=[#<Job:0xb70aa8f4 @attributes={"title"=>"Farmer", > "id"=>"4"}>]> > >> dj = u.jobs.find(4) > => #<Job:0xb7095c60 @attributes={"title"=>"Farmer", "id"=>"4"}> > >> u.jobs.delete(dj) > > Here are my classes > class Job < ActiveRecord::Base > has_many :user_jobs > has_many :users, :through => :user_jobs > end > > class User < ActiveRecord::Base > has_many :user_jobs > has_many :jobs, :through => :user_jobs > end > > class UserJob < ActiveRecord::Base > belongs_to :job > belongs_to :user > end > > Here is my schema > CREATE TABLE jobs ( > id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, > title TEXT NOT NULL > ); > CREATE TABLE user_jobs ( > user_id INTEGER NOT NULL, > job_id INTEGER NOT NULL, > PRIMARY KEY(user_id,job_id) > ); > CREATE TABLE users ( > id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, > name TEXT NOT NULL > ); > > rails 1.2.4 fron ubuntu. > > Any pointers would be great. > > thx -ants > > > > > Disclaimer: Technically, I''m always wrong!! > Support the World Aids Awareness campaign this month with Yahoo! for > Good > Sent from Yahoo! - a smarter inbox > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Noted, thx. I''m only playing around and have now gone back to habtm. Also went to rails 1.2.6. Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: On 19 Jan 2008, at 18:25, Anthony Gardner wrote:> Solved. Removed ubuntu''s rails and installed 2.0.2 using gems. > Everything works as it should. >That may be the case, but this will probably popup later on: with has_many :through, UserJob is a genuine model so should have a primary_key. Fred> Anthony Gardner wrote: I''m receiving the > following error .... > > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such > column: id: UPDATE user_jobs SET user_id = NULL WHERE (user_id = 1 > AND id IN (NULL)) > > while trying to delete from a join table. Here''s the sequence from > the console .... > > >> u = User.find(1) > => #"Anthony", "id"=>"1"}> > >> j= Job.find(4) > => #"Farmer", "id"=>"4"}> > >> u.jobs << j > => [#"Farmer", "id"=>"4"}>] > >> u > => # > @attributes={"job_id"=>"4", "user_id"=>"1"}>, # > @new_record=false, @attributes={"job_id"=>4, "id"=>1, "user_id"=>1}, > @errors=# > 0xb709e7d4 ...>, @errors={}>>], @attributes={"name"=>"Anthony", > "id"=>"1"}, @jobs=[#"Farmer", > "id"=>"4"}>]> > >> dj = u.jobs.find(4) > => #"Farmer", "id"=>"4"}> > >> u.jobs.delete(dj) > > Here are my classes > class Job < ActiveRecord::Base > has_many :user_jobs > has_many :users, :through => :user_jobs > end > > class User < ActiveRecord::Base > has_many :user_jobs > has_many :jobs, :through => :user_jobs > end > > class UserJob < ActiveRecord::Base > belongs_to :job > belongs_to :user > end > > Here is my schema > CREATE TABLE jobs ( > id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, > title TEXT NOT NULL > ); > CREATE TABLE user_jobs ( > user_id INTEGER NOT NULL, > job_id INTEGER NOT NULL, > PRIMARY KEY(user_id,job_id) > ); > CREATE TABLE users ( > id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, > name TEXT NOT NULL > ); > > rails 1.2.4 fron ubuntu. > > Any pointers would be great. > > thx -ants > > > > > Disclaimer: Technically, I''m always wrong!! > Support the World Aids Awareness campaign this month with Yahoo! for > Good > Sent from Yahoo! - a smarter inbox > >Disclaimer: Technically, I''m always wrong!! --------------------------------- Support the World Aids Awareness campaign this month with Yahoo! for Good --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---