# How to access to the attributes of the middle table set up b

**URL:** <https://www.ruby-forum.com/t/how-to-access-to-the-attributes-of-the-middle-table-set-up-b/111831>\
**Category:** Rails\
**Created:** [August 11, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/how-to-access-to-the-attributes-of-the-middle-table-set-up-b/111831 "2007-08-11T21:27:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mister\_Yu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/22d042/32.png) [@Mister\_Yu](https://www.ruby-forum.com/u/Mister_Yu)\
**Post date:** [August 11, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/how-to-access-to-the-attributes-of-the-middle-table-set-up-b/111831/1 "2007-08-11T21:27:31Z")

</div>

Hello all,

i have 3 models here:

place:  
…  
#the users who visited the place  
has\_many :visiteds  
has\_many :visitors, :through=\>:visiteds, :source=\>:user

user:  
…  
#the places this user has visited  
has\_many :visiteds  
has\_many :visited\_places, :through=\>:visiteds, :source=\>:place

visited: (id, user\_id, place\_id, recommended(boolean) )  
class Visited \< ActiveRecord::Base  
belongs\_to :user  
belongs\_to :place  
end

a user can “been to” a place using:  
visited = a\_place.visiteds.build(:recommended =\> true)  
visited.user = a\_user  
visited.save!

but how do i access back to the attributes of the middle table?  
currently, i m doing this:  
visited =  
current\_user.visiteds.find(:first, :conditions=\>[“place\_id  
= ?” ,placeid])  
recommand = visited.recommended  
but this looks quite stupid, is there any “built-in” way i can do  
this?

Thank you.
