Class: UsersController
Instance Method Summary
collapse
#current_navable, #current_navable=, #current_user, #point_navigation_to, #redirect_www_subdomain, #set_locale
Instance Method Details
#autocomplete_title ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
|
# File 'app/controllers/users_controller.rb', line 61
def autocomplete_title
query = params[:term] if params[ :term ]
query ||= params[ :query ] if params[ :query ]
query ||= ""
@users = User.where("CONCAT(first_name, ' ', last_name) LIKE ?", "%#{query}%")
render json: @users.map(&:title)
end
|
#create ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/controllers/users_controller.rb', line 40
def create
@user_params = user_params
@basic_user_params = @user_params.select { |key, value| key.to_s.in? ['first_name', 'last_name', 'email', 'female', 'create_account'] }
@basic_user_params[:first_name] ||= I18n.t(:first_name)
@basic_user_params[:last_name] ||= I18n.t(:last_name)
@user = User.create(@basic_user_params)
if @user_params[:add_to_group]
Group.find(@user_params[:add_to_group]).assign_user @user
@user_params.except! :add_to_group
end
@user.update_attributes(@user_params)
@user.fill_in_template_profile_information
@user.send_welcome_email if @user.account
redirect_to @user
end
|
#forgot_password ⇒ Object
73
74
75
76
77
78
|
# File 'app/controllers/users_controller.rb', line 73
def forgot_password
authorize! :update, @user.account
@user.account.send_new_password
flash[:notice] = I18n.t(:new_password_has_been_sent_to, user_name: @user.title)
redirect_to :back
end
|
#index ⇒ Object
9
10
11
12
13
14
15
|
# File 'app/controllers/users_controller.rb', line 9
def index
begin
redirect_to group_path(Group.everyone)
rescue
raise "No basic groups are present, yet. Try `rake bootstrap:all`."
end
end
|
#new ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'app/controllers/users_controller.rb', line 31
def new
@user = User.new
@parent_group = Group.find(params[:parent_id]) if params[:parent_type] == 'Group'
@user.add_to_group = @parent_group.try(:id)
@user.female = false
@user.alias = params[:alias]
end
|
#show ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/users_controller.rb', line 17
def show
if current_user == @user
current_user.update_last_seen_activity("sieht sich sein eigenes Profil an", @user)
else
current_user.try(:update_last_seen_activity, "sieht sich das Profil von #{@user.title} an", @user)
end
respond_to do |format|
format.html end
metric_logger.log_event @user.attributes.merge({name: @user.name, title: @user.title}), type: :show_user
end
|
#update ⇒ Object
56
57
58
59
|
# File 'app/controllers/users_controller.rb', line 56
def update
@user.update_attributes(user_params)
respond_with @user
end
|