Displaying 2 results from an estimated 2 matches for "endorsee".
Did you mean:
endorse
2006 Feb 23
3
has_many reference
I am trying to do something right from Agile Web Dev with Rails book
and it does not work. I must be missing something obvious.
I have a one-to-many relationship:
class Draft < ActiveRecord::Base
has_many :endorsees
end
class Endorsees < ActiveRecord:: Base
belongs_to :draft
end
>From my reading, methinks I should be able to say:
d = Draft.new
d.endorsees << Endorsee.new
SQL (for mysql) is:
create table drafts (
id int not null auto_increment,
claim_id int not null,
primary key(id)...
2006 Feb 26
4
Creating objects with has_many :through relationship
Three tables:
users: id
clients: id
admin_contacts: user_id, client_id
class Client
has_many :admin_contacts
has_many :contacts, :through => :admin_contacts, :foreign_key => :user_id,
:class_name => ''User''
end
I added the :contacts for ease of use of grabbing the user objects
associated with the admin_contact.
This all works great, I can grab the Users that