Extreme rails nooby here. I am trying to do a simple call to a controller from a javascript file and am fairly stuck, research says I need a ajax request. Can you guys point me in the right direction?
Here is my controller - It simply returns a boolean
class ReferredFriend < ActiveRecord::Base
def refer_email_exists(email)
/return a boolean
Here is my javascript - obviously incorrect syntax, but you get my general idea
if ReferredFriend.refer_email_exists(message.get('to_email')) == 'true'
alert "That email already exists!"
the route to the controller is: app/models/referred_friend.rb
I put this in my routes file, however I'm guessing this is incorrect as well
resources :referred_friends do
get :refer_email_exists
end
Thanks for your help!