31 lines
770 B
Ruby
31 lines
770 B
Ruby
module MicroPostsHelper
|
|
|
|
def read_each_post user
|
|
micro_posts_array = []
|
|
micro_posts = user.micro_posts.all.order(post_time: :desc)
|
|
if !micro_posts.empty?
|
|
micro_posts.each do |micro_post|
|
|
x = Hash.new()
|
|
x["title"] = micro_post.title
|
|
x["content"] = micro_post.content
|
|
case micro_post.post_type
|
|
when 1
|
|
x["type"] = "新鲜事"
|
|
when 2
|
|
x["type"] = "组团信息"
|
|
when 3
|
|
x["type"] = "失物招领"
|
|
else
|
|
x["type"] = "新鲜事"
|
|
end
|
|
x["time"] = utc_time_to_local(micro_post.post_time)
|
|
x["peo_num"] = micro_post.engage_people
|
|
micro_posts_array << x
|
|
end
|
|
end
|
|
return micro_posts_array
|
|
end
|
|
|
|
|
|
end
|