From 662fc02a805a31736448b9c14e489d07d713e94e Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 3 Jul 2015 09:44:26 +0800 Subject: [PATCH] =?UTF-8?q?news=20author=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/news.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index fe0291e68..5ed3958ba 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -32,8 +32,13 @@ module Mobile news_expose :title expose :author,using: Mobile::Entities::User do |f, opt| - #n = f[:author] - f.author if f.respond_to?(:author) + obj = nil + if f.is_a?(::News) && f.respond_to?(:author) + obj = f.send(:author) + elsif f.is_a?(Hash) && f.key?(:author) + obj = f[:author] + end + obj end #作者id news_expose :author_id