Maybe: <%= link_to lecture.title, lecture.lecture_id %> <!-- -->
? -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Patrick Heneise Sent: Friday, May 22, 2009 1:45 AM To: [email protected] Subject: [Rails] nested habtm in views Hi folks, hope someone can help me with this: There are four tables: Courses (has_many) -> CourseModules (has_and_belongs_to_many) -> CourseModulesLectures (has_and_belongs_to_many) ->Lectures. I'd like to get a table with all courses, modules and lectures, which works quite fine: <% unless @course.course_modules.empty? %> <% @course.course_modules.each do |m| %> <%=h m.semester %> <%=h m.title %> <% unless m.lectures.empty? %> <% m.lectures.each do |lecture| %> <%= link_to lecture.title, lecture %> <!-- --> <% end %> <% end %> <% end %> <% end %> (stripped unnecessary lines) The problem is, that 'lecture' in the marked line refers to the id of the habtm-table 'CourseModulesLectures', and not to the correct id of the lecture. How can I fix that? Any ideas? Thanks a lot! -- Posted via http://www.ruby-forum.com/. GHC Confidentiality Statement This message and any attached files might contain confidential information protected by federal and state law. The information is intended only for the use of the individual(s) or entities originally named as addressees. The improper disclosure of such information may be subject to civil or criminal penalties. If this message reached you in error, please contact the sender and destroy this message. Disclosing, copying, forwarding, or distributing the information by unauthorized individuals or entities is strictly prohibited by law. --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

