#!/usr/bin/env bash

# load rvm ruby
source /usr/local/rvm/environments/ruby-1.9.2-p290@projectX

bundle install
ruby /path/to/script.rb
rake do something
Source:

http://beginrescueend.com/integration/cron/
 

Before calling the ajax request, add this:

$.ajaxSetup({
‘beforeSend’: function(xhr) { xhr.setRequestHeader(‘X-CSRF-Token’, $(“meta[name='csrf-token']“).attr(‘content’)); }
});
then you can all the ajax reqeust after that:
$.ajax({
type: “POST”,
url: “/your-url-here”,
data:  $(form).serializeArray()
});
Make sure to add this in your view template:
<%= csrf_meta_tag %>
And add this javascript :
https://github.com/rails/jquery-ujs
Enjoy!