From 09b6f1d78792123c56364ba29f2d7fd58ad045d5 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 26 Jun 2015 17:16:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9news=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/news.rb | 6 ++++-- app/services/courses_service.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index f189771e3..7399ebb4c 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -26,13 +26,15 @@ module Mobile news_expose :title expose :author,using: Mobile::Entities::User do |f, opt| - n = f[:news] - n.author if n.respond_to?(:author) + n = f[:author] + #n.author if n.respond_to?(:author) end #作者id news_expose :author_id #作者名 news_expose :author_name + #作者头像url + news_expose :author_img_url #新闻内容 news_expose :description #发布时间 diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 29c4fb1b0..f5ff2670f 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -123,7 +123,7 @@ class CoursesService scope = @course ? @course.news.course_visible(current_user) : News.course_visible(current_user) news = [] scope.each do |n| - news << {:id => n.id,:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count} + news << {:id => n.id,:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :author=>n.author, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count} end news end