app/controllers/dogs/dogs_base_controller.rb
# Copyright 2017 Operation Paws for Homes
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# == Schema Information
#
# Table name: dogs
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
# tracking_id :integer
# primary_breed_id :integer
# secondary_breed_id :integer
# status :string(255)
# age :string(75)
# size :string(75)
# is_altered :boolean
# gender :string(6)
# is_special_needs :boolean
# no_dogs :boolean
# no_cats :boolean
# no_kids :boolean
# description :text
# foster_id :integer
# adoption_date :date
# is_uptodateonshots :boolean default(TRUE)
# intake_dt :date
# available_on_dt :date
# has_medical_need :boolean default(FALSE)
# is_high_priority :boolean default(FALSE)
# needs_photos :boolean default(FALSE)
# has_behavior_problem :boolean default(FALSE)
# needs_foster :boolean default(FALSE)
# petfinder_ad_url :string(255)
# craigslist_ad_url :string(255)
# youtube_video_url :string(255)
# first_shots :string(255)
# second_shots :string(255)
# third_shots :string(255)
# rabies :string(255)
# heartworm :string(255)
# bordetella :string(255)
# microchip :string(255)
# original_name :string(255)
# fee :integer
# coordinator_id :integer
# sponsored_by :string(255)
# shelter_id :integer
# medical_summary :text
#
class Dogs::DogsBaseController < ApplicationController
PER_PAGE = 30
def show
session[:last_dog_manager_search] ||= dogs_manager_index_url
@title = @dog.name
@og_image_path = @dog.primary_photo_url
@carousel = Carousel.new(@dog)
@adoptapet = Adoptapet.new(@dog.foster&.region)
flash.now[:danger]= render_to_string partial: 'dogs/unavailable_flash_message' if @dog.unavailable?
end
private
def load_dog
@dog = Dog.find(params[:id])
end
def for_page(page = nil)
@dogs = @dogs.paginate(per_page: PER_PAGE, page: page || 1)
end
end