Class: InvoiceBar::ContactsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /contacts POST /contacts.json



33
34
35
36
37
# File 'app/controllers/invoice_bar/contacts_controller.rb', line 33

def create
  @contact = InvoiceBar::Contact.new(contact_params)
  current_user.contacts << @contact
  respond_on_create @contact
end

#destroyObject

DELETE /contacts/1 DELETE /contacts/1.json



47
48
49
50
# File 'app/controllers/invoice_bar/contacts_controller.rb', line 47

def destroy
  @contact.destroy
  respond_on_destroy @contact, contact_url
end

#editObject

GET /contacts/1/edit



26
27
28
29
# File 'app/controllers/invoice_bar/contacts_controller.rb', line 26

def edit
  @contact.build_address unless @contact.address
  respond_on_edit @contact
end

#indexObject

GET /contacts GET /contacts.json



8
9
10
11
# File 'app/controllers/invoice_bar/contacts_controller.rb', line 8

def index
  @contacts = current_user.contacts.page(params[:page])
  respond_on_index @contacts
end

#newObject

GET /contacts/new



20
21
22
23
# File 'app/controllers/invoice_bar/contacts_controller.rb', line 20

def new
  @contact = InvoiceBar::Contact.new
  @contact.build_address
end

#showObject

GET /contacts/1 GET /contacts/1.json



15
16
17
# File 'app/controllers/invoice_bar/contacts_controller.rb', line 15

def show
  respond_on_show @contact
end

#updateObject

PATCH/PUT /contacts/1 PATCH/PUT /contacts/1.json



41
42
43
# File 'app/controllers/invoice_bar/contacts_controller.rb', line 41

def update
  respond_on_update @contact, contact_params
end