31 lines
1.1 KiB
Ruby
31 lines
1.1 KiB
Ruby
########fq
|
|
module TestHelper
|
|
def message_list(object)
|
|
object = object.reverse
|
|
remove_allowed = (User.current.id == object.first.user_id)
|
|
content = ''.html_safe
|
|
lis = object.each do |t_object|
|
|
s = ''.html_safe
|
|
s << avatar(t_object.user, :size => "16").to_s
|
|
s << link_to_user(t_object.find_messager.first, :class => 'user')
|
|
s << ':' + t_object.message
|
|
#time = '更新于' + time_tag(t_object.created_at) + '之前'
|
|
time = time_tag(t_object.created_at)
|
|
#s << content_tag('p', l(:field_add, time))
|
|
s << content_tag('div', time)
|
|
if remove_allowed
|
|
url = {:controller => 'test',
|
|
:action => 'destroy',
|
|
:object_id => t_object.id,
|
|
:user_id => User.current.id}
|
|
s << ' '
|
|
s << link_to(image_tag('delete.png'), url,
|
|
:remote => true, :method => 'delete', :class => "delete")
|
|
end
|
|
content << content_tag('li', s, :class => "user-#{t_object.messager_id}")
|
|
end
|
|
# content.present? ? content_tag('ul', content, :class => 'watchers') : content
|
|
content
|
|
end
|
|
end
|
|
|