it should say :action=>:add_point instead of :method=>:add_point.
Also, it wasn't all that surprising that my DB field wasn't getting updated: in that code, there had to be :id=>:video.id
without it, the controller wouldn't know which id to modify.
Thanks again katrina.
But, i want the increment to happen via Ajax so that it doesn't interfere with what is currently being rendered in the view.For example, if i have a video playing, and user clicks "vote" button, the video should continue playing, but the voting should happen in the background.
Right now, I have looked on the net for ways to deal with it, but not finding it.
I have used this in view:
But, not sure what the controller code should look like.So far the code I have seen all involves some form of rendering or redirecting which is not helping at all.
Please point me somewhere.
You will still need to send the id along to your add_points action.
If you're using rails 3, you may want to try something like this in your routes file:
Then your button code can look like this:
This way the video id will be passed to your controller.
You can call things whatever you like, this is just an example. The important things to note here are
1. :to => "controller#action" which needs to match your actual controller and action
2. :as => "some_name" which means you can refer to the route as some_name_path and some_name_url. This is called "named routes" if you want to google it.
Also, remember that you can call "rake routes" an the command line to see what your routes look like and how you can call them.
There are many other ways of writing the route you need. If your route file looks like this:
Then you can add some code like this:
Then call rake routes to see how to refer to this route in you button_to method. Probably something like