Class: Admin::AnimalWeightsController

Inherits:
CrudController
  • Object
show all
Defined in:
app/controllers/admin/animal_weights_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject

GET /animal_weights GET /animal_weights.xml


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

def index
  if params[:animal_id]
    @search = AnimalWeight.includes(:animal).organization(current_user).where(animal_id: params[:animal_id]).search(params[:q])
  else
    @search = AnimalWeight.includes(:animal).organization(current_user).search(params[:q])
  end
  @animal_weights = @search.result.paginate(:page => params[:page], :per_page => 10).order("updated_at DESC")
  @animals = Animal.organization(current_user).order("name")

  respond_with(@animal_weights) do |format|
    format.html
    format.csv { render :csv => AnimalWeight.includes(:animal).organization(current_user),
                        :filename => 'animal_weights' }
  end
end

#showObject

GET /animal_weights/1 GET /animal_weights/1.xml


33
34
35
36
37
38
# File 'app/controllers/admin/animal_weights_controller.rb', line 33

def show
  @animal_weight = AnimalWeight.find(params[:id])
  @animals = Animal.where(:organization_id => current_user.organization_id).collect{|x| [x.id.to_s,x.name.to_s]}
  
  respond_with(@animal_weight)
end