Class: Admin::AdoptAPetAccountsController

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

Instance Method Summary collapse

Instance Method Details

#createObject


5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/admin/adopt_a_pet_accounts_controller.rb', line 5

def create
  @adopt_a_pet_account = AdoptAPetAccount.new_by_user(, current_user)
  if @adopt_a_pet_account.save
    flash[:notice] = 'Adopt A Pet Account Connected!'
  else
    flash[:error] = 'Adopt A Pet Account Was Not Connected!'
  end
  
  redirect_to "#{root_url}admin/users/#{current_user.id}"
end

#destroyObject


42
43
44
45
46
47
48
49
50
# File 'app/controllers/admin/adopt_a_pet_accounts_controller.rb', line 42

def destroy
  @account = AdoptAPetAccount.find(params[:id])
  @account.destroy

  respond_to do |format|
    format.html {redirect_to("#{root_url}admin/users/#{current_user.id}", :notice => 'Adopt A Pet Account Deleted!')}
    format.xml  { head :ok }
  end
end

#send_animalObject


29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/admin/adopt_a_pet_accounts_controller.rb', line 29

def send_animal
  @account = AdoptAPetAccount.find_by_user_id(current_user.id)
  if @account.blank?
    redirect_to("#{root_url}admin/users/#{current_user.id}", :notice => 'Please Add Adopt A Pet Credentials!')
  else
    if @account.send_csv(current_user)
      redirect_to("#{root_url}admin/animals", :notice => 'Animals Sent To Adopt A Pet!')
    else
      redirect_to("#{root_url}admin/animals", :alert => 'Problem Sending Animals To Adopt A Pet!')
    end
  end
end

#updateObject


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

def update
  @adopt_a_pet = AdoptAPetAccount.find(params[:id])
  params[:adopt_a_pet_account]["password"] = SecPass::encrypt(params[:adopt_a_pet_account]["password"])
  respond_to do |format|
    if  @adopt_a_pet.update_attributes()
      format.html {redirect_to("#{root_url}admin/users/#{current_user.id}", :notice => 'Adopt A Pet Account updated!')}
    else
      format.html { render "new" }
    end
  end
end