0
I have 2 tables: user
and contact
, and created a third to connect the two: user_contact
:
class User < ActiveRecord::Base
has_many:user_contacts
end
class Contact < ActiveRecord::Base
has_many:user_contacts
end
class UserPaciente < ActiveRecord::Base
belongs_to:user
belongs_to:paciente
end
I have this controller
:
def index
@contacts = UserContact.where(:user_id => current_user.id)
end
And this view
:
<tbody>
<% @contacts.each do |contact| %>
<tr>
<td><%= contact.contact.id %></td>
</tr>
<% end %>
I’ve tried everything, but it doesn’t work, how can I find the list of contacts
of current_user
?
"I have 3 tables" but you speak of 2... (?) and "does not work" is not an adequate description... what happens? You can [Edit] ask to add more details.
– brasofilo
I’ve already edited, I hope to be more explicit
– Jorge