Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PublicController < ApplicationController
- def rehome
- @animals = Animal.animals_rehome.paginate(:page => params[:page], :per_page => 6)
- respond_to do |format|
- format.html
- format.js
- end
- end
- def rehomed
- respond_to do |format|
- format.js {render :json => Animal.where(animal_type: params[:animal_type]) }
- end
- end
- $('select.btn').on('change', function() {
- var animal_type = $('#animalType option:selected').text();
- var animal_town = $('#animalTown option:selected').text();
- $.ajax({
- type: 'POST',
- url: '/public/rehomed',
- data: {
- animal_type: animal_type,
- },
- success: function(data) {
- console.log(data);
- }
- });
- });
- @animals = Animal.animals_rehome.paginate(:page => params[:page], :per_page => 6)
- @animals = rehomed.paginate(:page => params[:page], :per_page => 6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement