Firefox 19 and unable to obtain stable firefox connection in 60 seconds

Problem
You have just upgraded your Firefox to the latest release (currently 19) and when running your javascript cucumber tests you get the following error:

 unable to obtain stable firefox connection in 60 seconds

Solution
Add the latest selenium-webdriver to your Gemfile and run bundle update:

gem "selenium-webdriver", "~> 2.30.0", :group => :test

Adding a record in Rails through javascript

Problem

You would like to trigger a record insertion after a specific action has happened through javascript (ie drag – drop an item into a container), in a rails application.

 

Solution

You would need to get the object attributes from the html page somehow (ie user_id and user_name), and then have a function in your application js that calls the post function.

So if you have a drag and drop container for example then the code in the application.js should be like the following:

$("#name_of_container").droppable({
  drop: handleDropEvent
});

function handleDropEvent(event,ui) {
  var user_id = ui.draggable.attr("user_id");
  var user_name = ui.draggable.attr("user_name");
  $.post('/users', {user: {user_id: user_id, name: user_name}})
}