title: Passing the variables from from jquery to rails controller
body: <p>I need to pass a variable which is captured from client side via jquery to controller, so that it can be used in the server side. After googling a bit, I found that we can pass it via an Ajax call.</p>
  
  <p><strong>routes.rb</strong></p>
  
  <pre><code>get "mymethod?Id=", :to =&gt; "sample#mymethod"
  </code></pre>
  
  <p><strong>j1.js</strong></p>
  
  <pre><code>$(function(){
  
  var test = 1;
  
  $(.btn).click(function(){
  
    $.ajax({
             url: '/mymethod?Id='+ test,
             success: function(data) {
                   }
           });
      });
  
  });
  </code></pre>
  
  <p><strong>sample_controller.rb</strong></p>
  
  <pre><code>def mymethod
   session[:Id] = params["Id"];
  end
  </code></pre>
  
  <p>When I try to use session[:Id], it is always nil.</p>
  
  <p>Any ideas,</p>
  
  <p>Thanks</p>