From 8fe5fee0f0da968d04e9ad6b66e58fdf2bfc9aff Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 23 Dec 2014 09:44:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/course.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb index b9823d9ac..8e5609f32 100644 --- a/app/api/mobile/entities/course.rb +++ b/app/api/mobile/entities/course.rb @@ -3,10 +3,17 @@ module Mobile class Course < Grape::Entity def self.course_expose(field) expose field do |f,opt| - f[:course][field] || f[:course].__send__(field) + o = nil + o = f.img_url if f.respond_to?(:img_url) + if f.is_a? ::Course + o = f.send(field) if f.respond_to?(field) + else + f[:course][field] || f[:course].__send__(field) + end + o end end - expose :img_url + course_expose :img_url course_expose :attachmenttype course_expose :class_period course_expose :code