Class: Blast::Contacts::ContactsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/blast/contacts/contacts_controller.rb', line 22

def create
  @contact = Contact.new(contact_params)
  @contact.user = current_user

  if @contact.save
    # Add blast to access the correct path
    redirect_to [blast, @contact],
                notice: 'Contact was successfully created.'
  else
    render :new
  end
end

#destroyObject



45
46
47
48
49
50
# File 'app/controllers/blast/contacts/contacts_controller.rb', line 45

def destroy
  @contact.destroy
  # Add blast to access the correct path
  redirect_to blast.contacts_url,
              notice: 'Contact was successfully destroyed.'
end

#editObject



19
20
# File 'app/controllers/blast/contacts/contacts_controller.rb', line 19

def edit
end

#indexObject



8
9
10
# File 'app/controllers/blast/contacts/contacts_controller.rb', line 8

def index
  @contacts = current_user.contacts
end

#newObject



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

def new
  @contact = Contact.new
end

#showObject



12
13
# File 'app/controllers/blast/contacts/contacts_controller.rb', line 12

def show
end

#updateObject



35
36
37
38
39
40
41
42
43
# File 'app/controllers/blast/contacts/contacts_controller.rb', line 35

def update
  if @contact.update(contact_params)
    # Add blast to access the correct path
    redirect_to [blast, @contact],
                notice: 'Contact was successfully updated.'
  else
    render :edit
  end
end