Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm coding a scrabble application and I want to call an update method when the player drops a tile so I change the position in the database

 function update_position(ev, posx, posy)
  {

    new Ajax.Request('/tiles_controller/update', {
    method: 'post',
    parameters: {
posx: posx
posy: posy}
                 });}`

and my controller looks like

  def update
    @tile = Tile.find(params[:id])
 @tile.update_attributes(params[:tile])
      end
    end
  end

I know the controller doesn't work I'm newbie coding in rails and I'm not sure how to pass the parameters from the javascript.

Please help

share|improve this question

1 Answer

You can add the url like this :

new Ajax.Request('<%= tile_update_path %>'

and there are several techniques to pass javascript data from your controller. There is a gem called gon . you can try it

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.