Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ScammersController < ApplicationController
- def index
- headers['Last-Modified'] = Time.now.httpdate
- headers['Content-Type'] = 'text/html'
- if params.has_key?(:search_val)
- @search_term = params[:search_val]
- # Here's where it's going to get sticky, I want to be able to pass a string value here,
- # and I will check to see if it's an email or a phone number; I'll use a JS plugin
- # on the client to validate the field as either phone number or email to add some
- # security on that front
- if is_valid_email?(@search_term)
- # It's an email address,
- @reccnt = Scammers.where(email_used: @search_term).count
- render :json => "{ 'message' : 'Email', 'count' : #{@reccnt} }"
- elsif is_valid_phone?(@search_term)
- # It's a phone number,
- render :json => "{ 'message' : 'Phone' }"
- else
- render :json => "{ 'message' : 'Invalid search term' }"
- end
- # Return the message value
- # render text: @search_term
- else
- render :json => "{ 'message' : 'Invalid search term' }"
- end
- end
- def show
- return params
- end
- def new
- end
- def create
- end
- def edit
- end
- def update
- end
- def destroy
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment