2009/8/28 Kart
<akramwasim1234-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:>
> hi all,
> consider that I''m having 3 models
> 1)user
> 2)doc
> 3)udoc
>
> user model=>(id,name)
> has_many:udocs
> has_many:docs ,through:udocs
>
> doc Model=>(id,name)
> has_many:udocs
> has_many:users ,through:udocs
>
> udoc Model=>(id,user_id,doc_id,start_date,end_date)
> belongs_to:user
> belongs_to;doc
>
> Can anybody just tell how to access the extra field (start_date and
> end_date) in udocs table
> by using User Model
Assuming you have a user in, say, @user, then @user.udocs will give
you an array of Udoc objects so you can do things like
@user.udocs[0].start_date
or
@user.udocs.each do |udoc|
# do something with udoc.end_date
end
Colin