I have the following setup
class Education < ActiveRecord::Base
has_and_belongs_to_many :users
end
class User < ActiveRecord::Base
has_and_belongs_to_many :educations
end
In my user-view-rhtml i have:
<% @user.educations do |education| %>
<li><%= education.name%></li>
This generates empty data...
Question...is my .rhtml wrong or my models??
--
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
-~----------~----~----~----~------~----~------~--~---
On 8 Nov 2007, at 15:01, Remco Swoany wrote:> > I have the following setup > > class Education < ActiveRecord::Base > has_and_belongs_to_many :users > end > > class User < ActiveRecord::Base > has_and_belongs_to_many :educations > end > > In my user-view-rhtml i have: > > <% @user.educations do |education| %> > <li><%= education.name%></li>That seems ok. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 8 Nov 2007, at 15:01, Remco Swoany wrote: > >> >> In my user-view-rhtml i have: >> >> <% @user.educations do |education| %> >> <li><%= education.name%></li> > > That seems ok. > > Fredyep...i thought so There is a join table education_user involved...that is the problem..i guess... -- 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 -~----------~----~----~----~------~----~------~--~---
I think the problems is in the iteration in your view, it should be:
<% @user.educations.each do |education| %>
<li><%= education.name%></li>
CU
Geoffroy Gomet
Joan Gu wrote:>
>
> Frederick Cheung wrote:
>> On 8 Nov 2007, at 15:01, Remco Swoany wrote:
>>
>>>
>>> In my user-view-rhtml i have:
>>>
>>> <% @user.educations do |education| %>
>>> <li><%= education.name%></li>
>>
>> That seems ok.
>>
>> Fred
>
> yep...i thought so
>
> There is a join table education_user involved...that is the problem..i
> guess...
>
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
>
--
View this message in context:
http://www.nabble.com/Correct-HABTM-of-use-has_many-%3Athrough--tf4771440.html#a13762790
Sent from the RubyOnRails Users mailing list archive at Nabble.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
-~----------~----~----~----~------~----~------~--~---
webapart wrote:> I think the problems is in the iteration in your view, it should be: > <% @user.educations.each do |education| %> > <li><%= education.name%></li> > > > CU > > Geoffroy Gomet > > > Joan Gu wrote: >>> >> -- >> Posted via http://www.ruby-forum.com/. >> >> > >> >> > > -- > View this message in context: > http://www.nabble.com/Correct-HABTM-of-use-has_many-%3Athrough--tf4771440.html#a13762790 > Sent from the RubyOnRails Users mailing list archive at Nabble.com.Geoffroy It is working now!!!!.... Thanks!!! remco -- 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 -~----------~----~----~----~------~----~------~--~---