Class: Eboshi::ClientsController

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

Instance Method Summary collapse

Methods included from ShallowRouteHelper

#assignment_path, #assignments_path, #convert_work_path, #edit_adjustment_path, #edit_invoice_path, #edit_work_path, #invoice_path, #invoices_path, #line_item_path, #merge_works_path, #new_adjustment_path, #new_assignment_path, #new_invoice_path, #new_payment_path, #payments_path, #work_path

Instance Method Details

#createObject



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

def create
  @client = Client.new(params[:client])
  if @client.save
    @client.users << current_user
    redirect_to clients_path, notice: "Client successfully created."
  else
    render :new
  end
end

#destroyObject



34
35
36
37
38
# File 'app/controllers/eboshi/clients_controller.rb', line 34

def destroy
  @client = current_user.clients.find params[:id]
  @client.destroy
  redirect_to clients_path
end

#editObject



11
12
13
# File 'app/controllers/eboshi/clients_controller.rb', line 11

def edit
  @client = current_user.clients.find(params[:id])
end

#indexObject



3
4
5
# File 'app/controllers/eboshi/clients_controller.rb', line 3

def index
  @clients = current_user.clients
end

#newObject



7
8
9
# File 'app/controllers/eboshi/clients_controller.rb', line 7

def new
  @client = Client.new
end

#updateObject



25
26
27
28
29
30
31
32
# File 'app/controllers/eboshi/clients_controller.rb', line 25

def update
  @client = current_user.clients.find(params[:id])
  if @client.update(params[:client])
    redirect_to clients_path, notice: "Client successfully updated."
  else
    render :edit
  end
end