# Beginner on Rails: need help urgent

**URL:** <https://www.ruby-forum.com/t/beginner-on-rails-need-help-urgent/136020>\
**Category:** Rails\
**Created:** [April 28, 2008, 7:33am UTC](https://www.ruby-forum.com/t/beginner-on-rails-need-help-urgent/136020 "2008-04-28T07:33:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanekcwu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7c8e57/32.png) [@kanekcwu](https://www.ruby-forum.com/u/kanekcwu)\
**Post date:** [April 28, 2008, 7:33am UTC](https://www.ruby-forum.com/t/beginner-on-rails-need-help-urgent/136020/1 "2008-04-28T07:33:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kanekcwu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7c8e57/32.png) [@kanekcwu](https://www.ruby-forum.com/u/kanekcwu)\
**Post date:** [April 28, 2008, 8:23am UTC](https://www.ruby-forum.com/t/beginner-on-rails-need-help-urgent/136020/2 "2008-04-28T08:23:04Z")

</div>

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.

Reinhart  
[http://teapoci.blogspot.com](http://teapoci.blogspot.com)

---

<div class="post-metadata">

**Author:** ![kanekcwu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7c8e57/32.png) [@kanekcwu](https://www.ruby-forum.com/u/kanekcwu)\
**Post date:** [April 28, 2008, 9:34pm UTC](https://www.ruby-forum.com/t/beginner-on-rails-need-help-urgent/136020/3 "2008-04-28T21:34:30Z")

</div>

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. 🙂

-Kyle

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