Class: User::EmailsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/user/emails_controller.rb

Instance Method Summary collapse

Methods included from ApplicationSignInCallbacksConcern

#sign_in

Methods included from ApplicationPaginationConcern

#page_param

Methods included from ApplicationAnnouncementsConcern

#global_announcements, #unread_global_announcements

Methods included from ApplicationInstanceUserConcern

#current_instance_user

Methods included from ApplicationUserTimeZoneConcern

#set_time_zone

Methods included from ApplicationUserConcern

#handle_access_denied, #publicly_accessible?

Methods included from ApplicationComponentsConcern

#handle_component_not_found

Instance Method Details

#createObject

:nodoc:


10
11
12
13
14
15
16
# File 'app/controllers/user/emails_controller.rb', line 10

def create #:nodoc:
  if @email.save
    redirect_to user_emails_path, success: t('.success')
  else
    redirect_to user_emails_path, danger: @email.errors.full_messages.to_sentence
  end
end

#destroyObject

:nodoc


18
19
20
21
22
23
24
# File 'app/controllers/user/emails_controller.rb', line 18

def destroy #:nodoc
  if @email.destroy
    redirect_to user_emails_path, success: t('.success')
  else
    redirect_to user_emails_path, error: @email.errors.full_messages.to_sentence
  end
end

#indexObject

:nodoc:


6
7
8
# File 'app/controllers/user/emails_controller.rb', line 6

def index #:nodoc:
  @new_email = current_user.emails.build
end

#send_confirmationObject


36
37
38
39
40
41
42
43
# File 'app/controllers/user/emails_controller.rb', line 36

def send_confirmation
  if @email.confirmed?
    redirect_to user_emails_path, warning: t('.already_confirmed', email: @email.email)
  else
    @email.send_confirmation_instructions
    redirect_to user_emails_path, success: t('.success', email: @email.email)
  end
end

#set_primaryObject

Set an email as the primary email


27
28
29
30
31
32
33
34
# File 'app/controllers/user/emails_controller.rb', line 27

def set_primary
  current_user.email = @email.email
  if current_user.save
    redirect_to user_emails_path, success: t('.success')
  else
    redirect_to user_emails_path, error: @email.errors.full_messages.to_sentence
  end
end