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
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
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
u = User.find(1)
0xb709e7d4 …>, @errors={}>>], @attributes={“name”=>“Anthony”,
end
CREATE TABLE users (
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.