Guest User

scammers_controller.rb

a guest
Jul 30th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1.  
  2. class ScammersController < ApplicationController
  3. def index
  4. headers['Last-Modified'] = Time.now.httpdate
  5. headers['Content-Type'] = 'text/html'
  6. if params.has_key?(:search_val)
  7. @search_term = params[:search_val]
  8.  
  9. # Here's where it's going to get sticky, I want to be able to pass a string value here,
  10. # and I will check to see if it's an email or a phone number; I'll use a JS plugin
  11. # on the client to validate the field as either phone number or email to add some
  12. # security on that front
  13. if is_valid_email?(@search_term)
  14. # It's an email address,
  15. @reccnt = Scammers.where(email_used: @search_term).count
  16. render :json => "{ 'message' : 'Email', 'count' : #{@reccnt} }"
  17. elsif is_valid_phone?(@search_term)
  18. # It's a phone number,
  19. render :json => "{ 'message' : 'Phone' }"
  20. else
  21. render :json => "{ 'message' : 'Invalid search term' }"
  22. end
  23. # Return the message value
  24. # render text: @search_term
  25. else
  26. render :json => "{ 'message' : 'Invalid search term' }"
  27. end
  28. end
  29.  
  30. def show
  31. return params
  32. end
  33.  
  34. def new
  35.  
  36. end
  37.  
  38. def create
  39. end
  40.  
  41. def edit
  42. end
  43.  
  44. def update
  45. end
  46.  
  47. def destroy
  48. end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment