Class: ContactsController

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

Instance Method Summary collapse

Instance Method Details

#destroyObject



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

def destroy
  @contact.relation_ids = [current_subject.relation_reject.id]

  respond_to do |format|
    format.js
  end
end

#editObject



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

def edit
end

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/contacts_controller.rb', line 5

def index
  @contacts =
    total_contacts.
            merge(Actor.letter(params[:letter])).
            merge(Actor.name_search(params[:search])).
            related_by_param(params[:relation])

  respond_to do |format|
    format.html { @contacts = @contacts.page(params[:page]).per(10) }
    format.js { @contacts = @contacts.page(params[:page]).per(10) }
    format.json { render :text => to_json(@contacts) }
  end
end

#pendingObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/contacts_controller.rb', line 42

def pending
  total_contacts

  @contacts = current_subject.pending_contacts

  respond_to do |format|
    format.html {
      @contacts = Kaminari.paginate_array(@contacts).page(params[:page]).per(10)
      render :action => :index
    }
    format.js {
      @contacts = Kaminari.paginate_array(@contacts).page(params[:page]).per(10)
      render :action => :index
    }
  end
end

#updateObject



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

def update
  # FIXME: This should be in the model
  params[:contact][:relation_ids].present? &&
   params[:contact][:relation_ids].delete("0")

  if @contact.update_attributes(params[:contact])
    redirect_to @contact.receiver_subject
  else
    render :action => 'edit'
  end
end