Class: Georgia::MessagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/georgia/messages_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability, #current_locale

Instance Method Details

#destroyObject

Destroy multiple assets



17
18
19
20
21
22
23
24
# File 'app/controllers/georgia/messages_controller.rb', line 17

def destroy
  ids = params[:id].split(',')
  if @messages = Message.destroy(ids)
    render layout: false
  else
    head :internal_server_error
  end
end

#destroy_all_spamObject



26
27
28
29
30
31
32
# File 'app/controllers/georgia/messages_controller.rb', line 26

def destroy_all_spam
  if Message.spam.destroy_all
    redirect_to :back, notice: 'All spam messages have been successfully deleted.'
  else
    redirect_to :back, alert: 'Oups. Something went wrong.'
  end
end

#hamObject



48
49
50
51
52
53
54
55
56
# File 'app/controllers/georgia/messages_controller.rb', line 48

def ham
  @message = Message.find(params[:id])
  if @message.ham! == false
    @message.update_attribute(:spam, false)
    redirect_to :back, notice: 'Message successfully marked as ham.'
  else
    redirect_to :back, alert: 'Oups. Something went wrong.'
  end
end

#indexObject



9
10
11
# File 'app/controllers/georgia/messages_controller.rb', line 9

def index
  redirect_to action: :search
end

#searchObject



13
14
# File 'app/controllers/georgia/messages_controller.rb', line 13

def search
end

#showObject



34
35
36
# File 'app/controllers/georgia/messages_controller.rb', line 34

def show
  @message = Message.find(params[:id]).decorate
end

#spamObject



38
39
40
41
42
43
44
45
46
# File 'app/controllers/georgia/messages_controller.rb', line 38

def spam
  @message = Message.find(params[:id])
  if @message.spam!
    @message.update_attribute(:spam, true)
    redirect_to :back, notice: 'Message successfully marked as spam.'
  else
    redirect_to :back, alert: 'Oups. Something went wrong.'
  end
end