Class: IsotopeContacts::ContactsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/isotope_contacts/contacts_controller.rb', line 16

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

#destroyObject



42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/isotope_contacts/contacts_controller.rb', line 42

def destroy
  @contact = ::IsotopeContacts::Contact.find(params[:id])
  if @contact.destroy
    flash[:notice] = "Contact was deleted successfully."
    redirect_to contacts_path
  else
    flash[:error] = "There was a problem deleting the contact"
    redirect_to contacts_path
  end
end

#editObject



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

def edit
  @contact = ::IsotopeContacts::Contact.find(params[:id])
end

#indexObject



3
4
5
6
# File 'app/controllers/isotope_contacts/contacts_controller.rb', line 3

def index
  @search = ::IsotopeContacts::Contact.search(params[:search])
  @contacts = @search.all
end

#newObject



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

def new
  @contact = ::IsotopeContacts::Contact.new(params[:contact])
end

#showObject



12
13
14
# File 'app/controllers/isotope_contacts/contacts_controller.rb', line 12

def show
  @contact = ::IsotopeContacts::Contact.find(params[:id])
end

#updateObject



31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/isotope_contacts/contacts_controller.rb', line 31

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