Beginner on Rails: need help urgent

Hi, I just started using rails and is having a simple relationship
problem. I would be very grateful anyone can help me.

I created a has many relationship between sessions and work out with
sessions having many workouts. So I though that when I tried doing
<% for session in @sessions %>
<% for workout in session.workouts%>

<%=h workout.description%>
<%=h workout.sets%>
<%=h workout.reps%>

<% end %>
<% end %>

I thought it would show all the workout that has a session id
corresponding to that session. In the database under workout that is a
session_id column. Do I have to do anything with that? Should I create a
workout_id column under session? Any help woudl be apperciated thanks.

hello Sir Wu :

in WORKOUTS table you should put session_id column.

In class Session < ActiveRecord put :
has_many :workouts

In class Workout < ActiveRecord put:
belongs_to :session

It should work in this case.


Beware of your session model potentially conflicting with the built-in
session hash (where session data may be stored). You might consider
changing the name of your model if you run into problems - or before
you run into them. :slight_smile:


On Apr 28, 1:23 am, Visit Indonesia 2008 <rails-mailing-l…@andreas-

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs