has_many :through

4 views
Skip to first unread message

ericindc

unread,
Sep 3, 2010, 11:50:41 AM9/3/10
to pickle
I've included what I have so far, but am a little stuck on how to get
the homes to belong to "Freddy". I think I'm getting close with
members --> [the last user], but I keep getting the error expected
"User" got "String". Thanks in advance.


Background:
Given I am registered and logged in as "fre...@krueger.net/
elmstreet"
And the following addresses exist
| address_1 |
| 250 Constitution Ave |
| 26 Market Place |
And the following homes exist
| label | address |
| Home 1 | the 1st address |
| Home 2 | the 2nd address |


class Home < ActiveRecord::Base
belongs_to :user
has_many :home_members
has_many :members, :through => :home_members, :class_name =>
'User', :source => :user
has_one :address
end

class User < ActiveRecord::Base
has_one :profile
has_many :home_members
has_many :homes, :through => :home_members
end
Reply all
Reply to author
Forward
0 new messages