Class: Kommandant::CommandsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/kommandant/commands_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/kommandant/commands_controller.rb', line 15

def create
  @command = Kommandant::Command.new(command_params_with_translations)

  if @command.save
    redirect_to commands_path, notice: "Command was successfully created."
  else
    render :new
  end
end

#destroyObject



44
45
46
47
48
# File 'app/controllers/kommandant/commands_controller.rb', line 44

def destroy
  @command.destroy

  redirect_to commands_path, notice: "Command was successfully destroyed."
end

#editObject



33
34
# File 'app/controllers/kommandant/commands_controller.rb', line 33

def edit
end

#indexObject



7
8
9
# File 'app/controllers/kommandant/commands_controller.rb', line 7

def index
  @commands = Kommandant::Command.all
end

#newObject



11
12
13
# File 'app/controllers/kommandant/commands_controller.rb', line 11

def new
  @command = Kommandant::Command.new
end

#showObject



25
26
27
28
29
30
31
# File 'app/controllers/kommandant/commands_controller.rb', line 25

def show
  if Kommandant.config.recent_commands.enabled
    current_user.recent_commands.prepend(@command.id)
  end

  render :show, layout: false
end

#updateObject



36
37
38
39
40
41
42
# File 'app/controllers/kommandant/commands_controller.rb', line 36

def update
  if @command.update(command_params_with_translations)
    redirect_to commands_path, notice: "Command was successfully updated."
  else
    render :edit
  end
end