Skip to content

Instantly share code, notes, and snippets.

@iwada
Created March 6, 2013 17:56
Show Gist options
  • Save iwada/5101480 to your computer and use it in GitHub Desktop.
Save iwada/5101480 to your computer and use it in GitHub Desktop.
#course_helper
def coursenames(courseid)
@coursedept = Department.all(:include => :courses, :conditions => ["courses.id = ?",courseid])
for i in @coursedept
return i.name #return the department's name
end
end
<% @course.each do |course| %>
<tr>
<td><%= course.code %></td>
<td><%= course.name %></td>
<td><%= coursenames(course.id) %>
</td> ...
#Assuming a course belongs to more than one Department,this only shows the first Department the course belongs to.
#How do i please get the rest as a comma seperated list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment