Currently working on a scrabble application and aiming to trigger an update method once the player moves a tile, updating its position within the database.
function changeTilePosition(event, posX, posY)
{
new Ajax.Request('/tiles_controller/update', {
method: 'post',
parameters: {
posX: posX,
posY: posY
}
});
}
Here's how my controller is set up:
def update
@tile = Tile.find(params[:id])
@tile.update_attributes(params[:tile])
end
I'm aware that my controller code isn't functioning correctly. I am fairly new to Rails and unsure of how to properly pass parameters from JavaScript to the server.
Your assistance would be greatly appreciated.