Class: Gaku::ContactsController

Inherits:
GakuController show all
Includes:
PolymorphicResourceConcern
Defined in:
app/controllers/gaku/contacts_controller.rb

Instance Method Summary collapse

Methods inherited from GakuController

#resolve_layout

Instance Method Details

#createObject



24
25
26
27
28
29
30
# File 'app/controllers/gaku/contacts_controller.rb', line 24

def create
  creator = ContactCreation.new(contact_params.merge(contactable: @polymorphic_resource))
  creator.save
  @contact = creator.contact
  set_count
  respond_with @contact
end

#destroyObject



40
41
42
43
44
45
46
# File 'app/controllers/gaku/contacts_controller.rb', line 40

def destroy
  if @contact.destroy
    @polymorphic_resource.contacts.first.try(:make_primary) if @contact.primary?
  end
  set_count
  respond_with @contact
end

#editObject



32
33
# File 'app/controllers/gaku/contacts_controller.rb', line 32

def edit
end

#indexObject



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

def index
  @contacts = @polymorphic_resource.contacts
  respond_with @contacts
end

#make_primaryObject



48
49
50
51
# File 'app/controllers/gaku/contacts_controller.rb', line 48

def make_primary
  @contact.make_primary
  respond_with @contact
end

#newObject



19
20
21
22
# File 'app/controllers/gaku/contacts_controller.rb', line 19

def new
  @contact = Contact.new
  respond_with @contact
end

#updateObject



35
36
37
38
# File 'app/controllers/gaku/contacts_controller.rb', line 35

def update
  ContactUpdation.new(@contact).update(contact_params)
  respond_with @contact
end