Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. class PublicController < ApplicationController
  2.  
  3. def rehome
  4. @animals = Animal.animals_rehome.paginate(:page => params[:page], :per_page => 6)
  5. respond_to do |format|
  6. format.html
  7. format.js
  8. end
  9. end
  10.  
  11. def rehomed
  12. respond_to do |format|
  13. format.js {render :json => Animal.where(animal_type: params[:animal_type]) }
  14. end
  15. end
  16.  
  17. $('select.btn').on('change', function() {
  18. var animal_type = $('#animalType option:selected').text();
  19. var animal_town = $('#animalTown option:selected').text();
  20.  
  21. $.ajax({
  22. type: 'POST',
  23. url: '/public/rehomed',
  24. data: {
  25. animal_type: animal_type,
  26. },
  27. success: function(data) {
  28. console.log(data);
  29. }
  30. });
  31. });
  32.  
  33. @animals = Animal.animals_rehome.paginate(:page => params[:page], :per_page => 6)
  34.  
  35. @animals = rehomed.paginate(:page => params[:page], :per_page => 6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement