Attachment添加file_dir 属性

yutao
lizanle 10 years ago
parent d3d656f3b8
commit 5c648c9284

@ -14,9 +14,10 @@ module Mobile
f.send(field) f.send(field)
end end
else else
#case field case field
# when "" when :file_dir
#end "attachments/download/" << f.send(:id).to_s << '/'
end
end end
end end
end end
@ -27,6 +28,7 @@ module Mobile
attachment_expose :downloads attachment_expose :downloads
attachment_expose :quotes attachment_expose :quotes
attachment_expose :created_on attachment_expose :created_on
attachment_expose :file_dir
end end
end end
end end

@ -434,24 +434,15 @@ class CoursesService
# 课程课件 # 课程课件
def course_attachments params def course_attachments params
result = [] result = []
@course = Course.find(params[:course_id]) course = Course.find(params[:course_id])
@attachments = @course.attachments.order("created_on desc") attachments = course.attachments.order("created_on ")
if !params[:name].nil? && params[:name] != "" if !params[:name].nil? && params[:name] != ""
@attachments.each do |atta| attachments.each do |atta|
result << {:filename => atta.filename, result << atta if atta.filename.include?(params[:name])
:description => atta.description,
:downloads => atta.downloads,
:quotes => atta.quotes.nil? ? 0 :atta.quotes } if atta.filename.include?(params[:name])
end end
else else
@attachments.each do |atta| result = attachments
result << {:filename => atta.filename,
:description => atta.description,
:downloads => atta.downloads,
:quotes => atta.quotes.nil? ? 0 :atta.quotes }
end
end end
result result
end end

Loading…
Cancel
Save