Class: ActiveStix::CampaignsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/active_stix/campaigns_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /stix/campaigns POST /stix/campaigns.json



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/active_stix/campaigns_controller.rb', line 27

def create
  @campaign = ActiveStix::Campaign.new(stix_campaign_params)

  respond_to do |format|
    if @campaign.save
      ActiveStix::Relationship.relate(@campaign, @threat_actor, "attributed-to")
      format.html { redirect_to [@threat_actor, @campaign], notice: 'Campaign was successfully created.' }
      format.json { render :show, status: :created, location: @campaign }
    else
      format.html { render :new }
      format.json { render json: @campaign.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /stix/campaigns/1 DELETE /stix/campaigns/1.json



58
59
60
61
62
63
64
# File 'app/controllers/active_stix/campaigns_controller.rb', line 58

def destroy
  @campaign.destroy
  respond_to do |format|
    format.html { redirect_to stix_campaigns_url, notice: 'Campaign was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /stix/campaigns/1/edit



22
23
# File 'app/controllers/active_stix/campaigns_controller.rb', line 22

def edit
end

#indexObject

GET /stix/campaigns GET /stix/campaigns.json



7
8
9
# File 'app/controllers/active_stix/campaigns_controller.rb', line 7

def index
  @campaigns = ActiveStix::Campaign.all
end

#newObject

GET /stix/campaigns/new



17
18
19
# File 'app/controllers/active_stix/campaigns_controller.rb', line 17

def new
  @campaign = ActiveStix::Campaign.new
end

#showObject

GET /stix/campaigns/1 GET /stix/campaigns/1.json



13
14
# File 'app/controllers/active_stix/campaigns_controller.rb', line 13

def show
end

#updateObject

PATCH/PUT /stix/campaigns/1 PATCH/PUT /stix/campaigns/1.json



44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/active_stix/campaigns_controller.rb', line 44

def update
  respond_to do |format|
    if @campaign.update(stix_campaign_params)
      format.html { redirect_to @campaign, notice: 'Campaign was successfully updated.' }
      format.json { render :show, status: :ok, location: @campaign }
    else
      format.html { render :edit }
      format.json { render json: @campaign.errors, status: :unprocessable_entity }
    end
  end
end