Class: PrintHostsController

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

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



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

def create
  @print_host = PrintHost.new(print_host_params)
  authorize @print_host
  respond_to do |format|
    format.html do
      if @print_host.save
        redirect_to print_hosts_path, notice: t(".success")
      else
        render Views::PrintHosts::New.new(print_host: @print_host), status: :unprocessable_content
      end
    end
  end
end

#destroy ⇒ Object



53
54
55
56
57
58
# File 'app/controllers/print_hosts_controller.rb', line 53

def destroy
  @print_host.destroy!
  respond_to do |format|
    format.html { redirect_to print_hosts_path, notice: t(".success"), status: :see_other }
  end
end

#edit ⇒ Object



21
22
23
24
25
# File 'app/controllers/print_hosts_controller.rb', line 21

def edit
  respond_to do |format|
    format.html { render Views::PrintHosts::Edit.new(print_host: @print_host) }
  end
end

#index ⇒ Object



5
6
7
8
9
10
11
# File 'app/controllers/print_hosts_controller.rb', line 5

def index
  authorize PrintHost
  @print_hosts = policy_scope(PrintHost).all
  respond_to do |format|
    format.html { render Views::PrintHosts::Index.new(print_hosts: @print_hosts) }
  end
end

#new ⇒ Object



13
14
15
16
17
18
19
# File 'app/controllers/print_hosts_controller.rb', line 13

def new
  @print_host = PrintHost.new
  authorize @print_host
  respond_to do |format|
    format.html { render Views::PrintHosts::New.new(print_host: @print_host) }
  end
end


60
61
62
63
64
65
# File 'app/controllers/print_hosts_controller.rb', line 60

def print
  @file = ModelFile.find_param(params[:file_id])
  authorize @file
  @print_host.print_later(file: @file)
  redirect_back_or_to model_model_file_path(@file.model, @file), notice: t(".sent"), status: :see_other
end

#update ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/print_hosts_controller.rb', line 41

def update
  respond_to do |format|
    format.html do
      if @print_host.update(print_host_params)
        redirect_to print_hosts_path, notice: t(".success"), status: :see_other
      else
        render Views::PrintHosts::Edit.new(print_host: @print_host), status: :unprocessable_content
      end
    end
  end
end