osem-fcy/app/controllers/admin/users_controller.rb

48 lines
1.3 KiB
Ruby
Raw Normal View History

2014-06-23 19:07:50 +03:00
module Admin
class UsersController < ApplicationController
2014-08-12 11:51:59 +03:00
load_and_authorize_resource
def new
@user = User.new
end
2013-01-07 09:04:09 +01:00
2014-06-23 19:07:50 +03:00
def index
@users = User.all
end
2013-01-07 09:04:09 +01:00
2014-06-23 19:07:50 +03:00
def show
# Variable @show_attributes holds the attributes that are visible for the 'show' action
# If you want to change the attributes that are shown in the 'show' action of users
# add/remove the attributes in the following string array
2014-08-12 11:51:59 +03:00
@show_attributes = %w(name email affiliation biography registered attended roles created_at
2014-06-23 19:07:50 +03:00
updated_at sign_in_count current_sign_in_at last_sign_in_at
current_sign_in_ip last_sign_in_ip)
end
2014-06-23 19:07:50 +03:00
def update
2014-08-12 11:51:59 +03:00
params[:user].delete :roles_attributes if params[:user]
@user.update_attributes!(params[:user])
redirect_to admin_users_path, notice: "Updated #{@user.email}"
2014-06-23 19:07:50 +03:00
end
2014-08-12 11:51:59 +03:00
def add_role
role = params[:user][:roles_attributes][:"0"]
@user.add_role role['name'].parameterize.underscore.to_sym, Conference.find(role['resource_id'])
respond_to do |format|
format.html
format.js
end
2014-06-23 19:07:50 +03:00
end
2014-08-12 11:51:59 +03:00
def edit
2014-06-23 19:07:50 +03:00
end
def destroy
@user.destroy
2014-08-12 11:51:59 +03:00
redirect_to admin_users_path, notice: "User #{@user.name} (#{@user.email})got deleted"
2014-06-23 19:07:50 +03:00
end
end
end