socialforge/app/helpers/test_helper.rb

31 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2013-08-01 10:33:49 +08:00
########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