Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AnimalsController < ApplicationController
- def index
- @animals = Animal.all
- #@animals = @q.result
- #@animals - Animal.where(["owner Like ?","%#{params[:search]}%"])
- #@q = Animal.ransack(params[:q])
- end
- def show
- @animals = Animal.find(params[:id])
- end
- def edit
- @animals = Animal.find(params[:id])
- end
- def update
- @animals = Animal.find(params[:id])
- if @animals.update(animal_params)
- flash[:notice] = "Animal Log Successfully Updated!"
- redirect_to @animals
- else
- render :edit
- end
- end
- def new
- @animals = Animal.new
- end
- def create
- @animals = Animal.new(animal_params)
- @animals.save
- redirect_to @animals
- end
- def destroy
- @animals = Animal.find(params[:id])
- @animals.destroy
- redirect_to @animals
- end
- def image_for(animal)
- if animal.image_file_name.blank?
- image_tag('animals.jpg')
- else
- image_tag(animal.image_file_name)
- end
- end
- def animal_params
- params.require(:animal).permit(:animalname, :owner)
- end
- private
- def animal_params
- params.require(:animal).permit(:datemissing, :owner, :address, :phone, :description, :animalname, :notes, :sex)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement