解决成员列表获取单位不准确的问题

This commit is contained in:
huang 2016-07-21 09:27:14 +08:00
parent f979e80f24
commit 6357f5be2a
2 changed files with 6 additions and 2 deletions

View File

@ -38,6 +38,11 @@ module ApplicationHelper
# super
# end
# 获取用户单位
# 优先获取高校信息如果改信息不存在则获取occupation
def get_occupation_from_user user
School.where("id=?",user.user_extensions.school_id).first.try(:name).nil? ? user.user_extensions.occupation : School.where("id=?",user.user_extensions.school_id).first.try(:name)
end
def update_visiti_count container
container.update_column(:visits, container.visits + 1)

View File

@ -56,8 +56,7 @@
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" align="center" align="center"><%= checked_image user.admin? %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="created_on" align="center" title='<%=format_time(user.created_on)%>'><%= format_time(user.created_on) %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="last_login_on" align="center" title='<%= format_time(user.last_login_on)%>'><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
<% occupation = user.user_extensions.identity == 0 ? School.where("id=?",user.user_extensions.school_id).first.try(:name) : user.user_extensions.occupation %>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" align="center" align="center" title="<%= occupation %>"> <%= truncate( occupation, :length => 12 ) %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" align="center" align="center" title="<%= get_occupation_from_user(user) %>"> <%= truncate(get_occupation_from_user(user), :length => 12 ) %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="buttons" align="center" title='<%=user.id %>'> <%= change_status_link(user) %></td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="buttons" align="center" title='<%=user.id %>'> <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %></td>