summaryrefslogtreecommitdiff
path: root/app/controllers/intruders_controller.rb
blob: 99cb023aac3b81e6f789d7ebebc123ecd180dff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class IntrudersController < ApplicationController
  def index
    @intruders = Intruder.order('list_type ASC, contact_last DESC').all
    spread_breadcrumbs
  end

  def show
    @intruder = Intruder.find(params[:id])
    if ! params[:whois].blank?
      @whois = @intruder.whois(params[:whois])
    end
    spread_breadcrumbs
  end

  def new
    @intruder = Intruder.new
    spread_breadcrumbs
  end

  def create
    @intruder = Intruder.new(params[:intruder])
    spread_breadcrumbs
    if @intruder.save
      redirect_to @intruder, :notice => t('intruders.controller.successfuly_created')
    else
      render :new
    end
  end

  def edit
    @intruder = Intruder.find(params[:id])
    spread_breadcrumbs
  end

  def update
    @intruder = Intruder.find(params[:id])
    spread_breadcrumbs
    if @intruder.update_attributes(params[:intruder])
      redirect_to @intruder, :notice  => t('intruders.controller.successfuly_updated')
    else
      render :edit
    end
  end

  def destroy
    @intruder = Intruder.find(params[:id])
    spread_breadcrumbs
    @intruder.destroy
    redirect_to intruders_url, :notice => t('intruders.controller.successfuly_destroyed')
  end

  private
  def spread_breadcrumbs
    add_breadcrumb t("intruders.index.page_title"), intruders_path
    if @intruder && !@intruder.new_record?
      add_breadcrumb @intruder, @intruder
    end
  end
end