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%>
<tr>
<td><%=h workout.description%></td>
<td><%=h workout.sets%></td>
<td><%=h workout.reps%></td>
</tr>
<% 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.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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- s.net> wrote:> 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. > > Reinharthttp://teapoci.blogspot.com > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---