Module: UsersHelper

Defined in:
app/helpers/users_helper.rb

Instance Method Summary collapse

Instance Method Details

#project_users_select_tag(user_element, default_name = nil) ⇒ Object



36
37
38
39
# File 'app/helpers/users_helper.rb', line 36

def project_users_select_tag(user_element, default_name = nil)
  user_id_list = User.in_project(sessions_current_project_id)
  user_select_tag(user_element, user_id_list, default_name)
end

#user_last_seen_tag(user) ⇒ Object



16
17
18
19
20
21
22
# File 'app/helpers/users_helper.rb', line 16

def user_last_seen_tag(user)
  if !user..blank?
    time_ago_in_words(user.) + '  ago'
  else
    (:em, 'never')
  end
end


8
9
10
11
12
13
14
# File 'app/helpers/users_helper.rb', line 8

def user_link(user)
  if sessions_current_user == user || sessions_current_user.is_administrator?
    link_to(user_tag(user), user)
  else
     :span, user_tag(user), class: :subtle
  end
end

#user_select_tag(user_element, user_id_list, default_name = nil) ⇒ HTML

Parameters:

  • user_element (Symbol, String)
  • user_id_list (Array)
  • default_name, (String)

    if supplied, must be a user.name, user.email, or user.if

Returns:

  • (HTML)


28
29
30
31
32
33
34
# File 'app/helpers/users_helper.rb', line 28

def user_select_tag(user_element, user_id_list, default_name = nil)
  select_tag(user_element,
             options_for_select(user_id_list
    .collect { |u| [User.find(u).name, User.find(u).id] }
    .unshift(['All users', 'All users']),
  default_name))
end

#user_select_tag_2(user_element, *users) ⇒ Object



41
42
43
44
45
46
47
# File 'app/helpers/users_helper.rb', line 41

def user_select_tag_2(user_element, *users)
  a = users
  select_tag(user_element, options_for_select(
    User
    .in_project(sessions_current_project_id)
    .collect { |u| [User.find(u).name, User.find(u).id] }))
end

#user_tag(user) ⇒ Object



3
4
5
6
# File 'app/helpers/users_helper.rb', line 3

def user_tag(user)
  return nil if user.nil?
  user.name
end