title: ajax get data from a rails controller
body: <p>I am trying to use ajax to get information from my controller. Basically I want to know if a data already exists in the DB or not, so my controller will return either true or false.
  At the moment I am just trying to set the basic ajax call</p>
  
  <p>in my js file I have the following ajax call, as you can see at the moment I am not really doing any logic because my data is just a placeholder. Later I will add the information I want to query </p>
  
  <pre><code>$.ajax({
    type: "GET",
    url: "/locations/exists",
    dataType: "JSON",
    data: { 'locition_exist': loc_exit },
    success: function(data) {
      console.log(data);
    }
  });
  </code></pre>
  
  <p>In my controller I have</p>
  
  <pre><code>  def exists
      location_exists = true
      respond_to do |format|
        format.html
        format.json {render json: location_exists }
      end
    end
  </code></pre>
  
  <p>Later value will go into a method in the model that will query the DB and return true/false.</p>
  
  <p>In my routes I have</p>
  
  <pre><code>  resources :locations 
    get 'locations/exists', to: 'locations#exists'
  </code></pre>
  
  <p>This code results in the following error</p>
  
  <pre><code>The action 'show' could not be found for LocationsController
  </code></pre>
  
  <p>I am new to rails and ajax , and I based my code on different examples that I read here, so I am probably just doing a stupid noob mistake.
  Thank you very much for your help</p>