Odd referrer issue

The request referrer is the URL you come from. It's set by the browser when you click a link (all browsers) and in Javascript click events too (all but the Internet Explorer family).

If you click a link on a page:

request.referer == request.referrer == request.env['HTTP_REFERER']

So far so good. But if you write the URL straight into the browser:

request.referer == request.env['HTTP_REFERER'] == nil

however

request.referrer == '/'

instead of nil.

This seems to happen in our current version of Rails, although not in Rails >= 3.x...

jQuery ajax success/done will not run callbacks if request is json but the response is empty (typical 200)

When using

var onDone = function() { ... }
var onFail = function() { ... }
var params = { ... }
var url = ...

$.ajax({
  type:  'put',
  url:  url,
  contentType: 'application/json; charset=utf-8',
  data:  JSON.stringify(params),
})
.done(onDone)
.fail(onFail);

Always make sure your rails controller returns something:

if @property.update_attributes(params[:property])
  render :json => { :ok => true }, :status => :ok
else
  render :json => { :ok => false }, :status => :unpro...

Killing wkhtmltopdf during cucumber

wkhtmltopdf hangs on mac during cucumber unless we click on it. The main reason is with the version we use which is 0.11.0_rc1 and in out app/bin we have another version and it is a known issue with these versions. The fix is to go to 0.9.9, to downgrade the version we installed earlier using brew:

* brew uninstall wkhtmltopdf
* brew update
* brew versions wkhtmltopdf
* if you see output like 
*         `0.9.9    git checkout 6e2d550 /usr/local/Library/Formula/wkhtmltopdf.rb`
           then `cd /usr/local`
* g...

To avoid using bundle exec or creating rvm gemsets

  1. Add to the end your .bash_profile export PATH="./vendor/bundle/bin:$PATH"
  2. Also add alias bi="bundle install --path vendor/bundle --binstubs=vendor/bundle/bin"
  3. Then to bundle install next time just use bi

Now no more bundle exec before any rake, cap, spec or anything else :)