J
John Griffiths
trying to work this out, giving me a headache,
basically i've got a data structure where you have teams, members and
users.
each team can have many members,
each member has one user, and is assigned to one team,
----------
class Team < ActiveRecord::Base
has_many :members, :class_name => 'Member'
validates_presence_of :team_name
end
----------
class Member < ActiveRecord::Base
belongs_to :team
has_one :user, :class_name => 'User'
end
----------
class User < ActiveRecord::Base
belongs_to :member
end
so now in my team:index page, i want to show all the users how are
members of a team.
i've tried...
controller...
@team = Team.find(self.current_user.member.team_id)
view...
<% for @member in @team.members %>
<td width="50%">
<%= render artial => 'user' %>
</td>
<% end %>
partial...
<% for @user in @member.users %>
<%= @user.email %>
<% end %>
...this in theory should work (and does up to the partial), once i get
to the partial, rails throws "undefined method 'users'"
any ideas where i've gone wrong?
basically i've got a data structure where you have teams, members and
users.
each team can have many members,
each member has one user, and is assigned to one team,
----------
class Team < ActiveRecord::Base
has_many :members, :class_name => 'Member'
validates_presence_of :team_name
end
----------
class Member < ActiveRecord::Base
belongs_to :team
has_one :user, :class_name => 'User'
end
----------
class User < ActiveRecord::Base
belongs_to :member
end
so now in my team:index page, i want to show all the users how are
members of a team.
i've tried...
controller...
@team = Team.find(self.current_user.member.team_id)
view...
<% for @member in @team.members %>
<td width="50%">
<%= render artial => 'user' %>
</td>
<% end %>
partial...
<% for @user in @member.users %>
<%= @user.email %>
<% end %>
...this in theory should work (and does up to the partial), once i get
to the partial, rails throws "undefined method 'users'"
any ideas where i've gone wrong?