From 9847bd670e2938b50a497810f0055ce55cde0ebd Mon Sep 17 00:00:00 2001 From: Jesper Josefsson Date: Tue, 8 May 2012 21:05:52 +0200 Subject: [PATCH] Add method to pretty print all course codes for given course [#164] --- app/models/given_course.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/given_course.rb b/app/models/given_course.rb index 96d5bb42..d20768b3 100644 --- a/app/models/given_course.rb +++ b/app/models/given_course.rb @@ -18,4 +18,9 @@ class GivenCourse < ActiveRecord::Base def register_student(student) StudentRegisteredForCourse.create!(student: student, given_course: self) end + + # @return String: All the course codes associated with the course + def all_course_codes + self.course.course_codes.map{|c| c.code}.join(" | ") + end end