Displaying 2 results from an estimated 2 matches for "length_in_issu".
Did you mean:
length_in_issues
2006 Apr 11
3
Validations and has_many :through (Join Models)
...uot;.
Here are the tables:
create_table :magazines do |t|
t.column :title, :string
end
create_table :readers do |t|
t.column :name, :string
end
create_table :subscriptions do |t|
t.column :reader_id, :integer
t.column :magazine_id, :integer
t.column :last_renewal_on, :date
t.column :length_in_issues, :integer
end
And here are the models:
class Subscription < ActiveRecord::Base
belongs_to :reader
belongs_to :magazine
end
class Reader < ActiveRecord::Base
has_many :subscriptions
has_many :magazines, :through => :subscriptions
end
class Magazine < ActiveRecord::Base
ha...
2006 Aug 03
12
More than one has_many :through association between the same 2 models
I wonder if you can have more than one has_many :through association between
2 models.
For example...
I have a model Teacher and a model Class
Now, 1 Teacher works in many Classes, right?. So I need a join model like
class Work < ActiveRecord::Base
belongs_to :teacher
belongs_to :class
end
But I also would like to know if a teacher CAN teach a class before I