Class: Admin::RelinquishmentContactsController

Inherits:
CrudController
  • Object
show all
Includes:
PublicActivity::StoreController
Defined in:
app/controllers/admin/relinquishment_contacts_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject

GET /relinquishment_contacts GET /relinquishment_contacts.xml


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/relinquishment_contacts_controller.rb', line 14

def index
  if params[:animal_id]
    @search = RelinquishmentContact.joins(:relinquish_animals).organization(current_user).where(relinquish_animals: {animal_id: params[:animal_id]}).search(params[:q])
  else
    @search = RelinquishmentContact.organization(current_user).search(params[:q])
  end
  @relinquishment_contacts = @search.result.paginate(:page => params[:page], :per_page => 10).order("updated_at DESC")
  @presenter = Admin::RelinquishmentContacts::IndexPresenter.new(current_user)
  respond_with(@relinquishment_contacts) do |format|
    format.html # index.html.erb
    format.csv { render :csv => RelinquishmentContact.organization(current_user),
                        :filename => 'relinquishment_contacts' }
  end
end

#showObject

GET /relinquishment_contacts/1 GET /relinquishment_contacts/1.xml


31
32
33
34
35
36
37
# File 'app/controllers/admin/relinquishment_contacts_controller.rb', line 31

def show
  @relinquishment_contact = RelinquishmentContact.find(params[:id])
  @animals = RelinquishmentContact.find(params[:id]).animals
  @relatable_animals = Animal.organization(current_user)
  
  respond_with(@relinquishment_contact)
end