I don't know much about Ruby/Rails, but the ideal solution would be to separate the HTML markup from the JavaScript. While you can still use the "onClick" event on the HTML element, it is generally a good practice to give the element an ID and/or Name and then allow JavasScript to bind to that element.
Here is a rough markup of using an ID value:
<%=button_to_function "✓", :class => "buttonGrey" :id => "myButton"%>
Then in your checkButton() method, update the calls to:
function checkButton()
{
if ($("#myButton").className=="buttonGrey") {
$("#myButton").removeClass('buttonGrey');
$("#myButton").addClass('buttonGreen');
}
if ($("#myButton").className=="buttonGreen") {
$("#myButton").removeClass('buttonGreen');
$("#myButton").addClass('buttonGrey');
}
}
Hope that helps, or at least steers you in the right direction :)