Class: IsotopeContacts::EmailsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/isotope_contacts/emails_controller.rb', line 9

def create
  @email = @contact.emails.new(params[:email])
  if @email.save
    flash[:notice] = "Email created successfully."
    redirect_to contact_path(@contact)
  else
    flash.now[:notice] = "There was a problem creating the email."
    render :new
  end
end

#destroyObject



35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/isotope_contacts/emails_controller.rb', line 35

def destroy
  @email = @contact.emails.find(params[:id])
  if @email.destroy
    flash[:notice] = "Email was deleted successfully."
    redirect_to contact_path(@contact)
  else
    flash.now[:error] = "There was a problem deleting the email"
    redirect_to contact_path(@contact)
  end
end

#editObject



20
21
22
# File 'app/controllers/isotope_contacts/emails_controller.rb', line 20

def edit
  @email = @contact.emails.find(params[:id])
end

#newObject



5
6
7
# File 'app/controllers/isotope_contacts/emails_controller.rb', line 5

def new
  @email = @contact.emails.new(params[:email])
end

#updateObject



24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/isotope_contacts/emails_controller.rb', line 24

def update
  @email = @contact.emails.find(params[:id])
  if @email.update_attributes(params[:email])
    flash[:notice] = "Email updated successfully."
    redirect_to contact_path(@contact)
  else
    flash.now[:notice] = "There was a problem updating the email."
    render :edit
  end
end