running rake task as cronjobs – rvm
On January 31, 2012,
in IT Related, Ruby on Rails,
by admin
#!/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/
Rails session lost when calling request via jquery/ajax
On January 8, 2012,
in IT Related, Ruby on Rails,
by admin
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
https://github.com/rails/jquery-ujs
Enjoy!

Recent Comments