From: Todd Benson Date: 2007-11-08T08:32:47+09:00 Subject: Re: Show info from table wich is joined On Nov 7, 2007 1:18 PM, Remco Swoany wrote: > Todd Benson wrote: > > On Nov 7, 2007 12:22 PM, Remco Swoany wrote: > >> > >> users. > > Are you trying to move away from the DB relational model (i.e. you > > plan to alter the DB), or just trying to get Ruby to work with it? > > > > By the sound of it, you have something in the DB that looks like > > (forgive the crude notation)... > > > > Users <-- Expertise --> Educations > > > > 3 tables? > > > > Todd > > I have 3 tables > > users > educations > educactions_users > > The educactions_users is my join table, with the columns users_id and > educations_id. > > A part of the user-edit-view looks like this, where the user can > specified there educations. This works..after getting grey hair!! > >

educations

> <% for education in Education.find(:all) %> >
> <%= check_box_tag "user[education_ids][]", education.id, > @user.educations.include?(education) %> > <%= education.name%> >
> <% end %> > > But..... > > In the show-view i want a list of educations wich the user has selected. > I thought this. > >

Educations

>
    > <% @user.educations do |education| %> >
  • <%= education.name%>
  • > <% end %> >
> > This get empty value.. > > This is my problem.. > > Grtz..remco > > -- > Posted via http://www.ruby-forum.com/. > > Have you tried specifying the word "through" in your rails models. This works for me, for example... class User < ActiveRecord::Base has_many :memberships has_many :groups, :through => :memberships end class Group < ActiveRecord::Base has_many :memberships has_many :users, :through => :memberships end class Membership < ActiveRecord::Base belongs_to :user belongs_to :group end hth a little, Todd