diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 64bb122..bb6c6cc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,6 +3,7 @@ class ApplicationController < ActionController::Base include ApplicationHelper include LoginHelper + include UsersHelper # Confirms a logged-in user. diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c58e6db..f13cf94 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5,4 +5,5 @@ module ApplicationHelper return intime.utc.in_time_zone('Beijing').strftime(format='%F %T') end + end diff --git a/app/helpers/micro_posts_helper.rb b/app/helpers/micro_posts_helper.rb index 9b5c3f2..58b1592 100644 --- a/app/helpers/micro_posts_helper.rb +++ b/app/helpers/micro_posts_helper.rb @@ -25,6 +25,8 @@ module MicroPostsHelper x["time"] = get_strftime(micro_post.post_time) x["pics"] = micro_post.pic.split(',') if micro_post.pic x["peo_num"] = micro_post.engage_people + x["peo_names"] = micro_post.engaged_people_names + x["comments"] = micro_post.comments micro_posts_array << x end end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 2310a24..29bebac 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,2 +1,6 @@ module UsersHelper + def get_user_name_from_id user_id + user = User.where(id: user_id) + return user.name if !user.empty? + end end diff --git a/app/views/micro_posts/show.html.erb b/app/views/micro_posts/show.html.erb index e783f00..61b1965 100644 --- a/app/views/micro_posts/show.html.erb +++ b/app/views/micro_posts/show.html.erb @@ -8,7 +8,7 @@
暂无评论
+ <% end %> +
+-
+
+ <%= get_user_name_from_id comment.user_id %>
+
+
+
+
+comment.content
+