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.