Class: Iron::UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/iron/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/iron/users_controller.rb', line 22

def create
  person = Person.new(join_params)
  @user = User.new(
    authenticatable: person,
    language: preferred_admin_language
  )

  if @user.save
    start_new_session_for @user
    redirect_to root_url
  else
    render :new, status: :unprocessable_entity
  end
rescue ActiveRecord::RecordNotUnique
  redirect_to (email_address: join_params[:email_address])
end

#destroyObject



39
40
41
42
43
44
45
# File 'app/controllers/iron/users_controller.rb', line 39

def destroy
  if @user.deactivate
    redirect_to users_path, notice: t("iron.users.notifications.removed"), status: :see_other
  else
    redirect_back fallback_location: users_path, alert: @user.errors.full_messages.to_sentence, status: :see_other
  end
end

#indexObject



10
11
12
13
# File 'app/controllers/iron/users_controller.rb', line 10

def index
  @users = User.people.active
  @deactivated_users = User.people.where(active: false)
end

#newObject



15
16
17
# File 'app/controllers/iron/users_controller.rb', line 15

def new
  @user = User.new
end

#showObject



19
20
# File 'app/controllers/iron/users_controller.rb', line 19

def show
end