heres what I’m currently using:
Rails -v 3.2.3
I’m trying to make a path in routes.rb that will route to a method in my links_controller.rb.
routes.rb
match 'modify_points' => 'links#modify_points', :as => :modify_points
links_controller.rb method
def modify_points
@link = Link.find(params[:id])
@link.update_attribute :points, @link.points + params[:by].to_i if params[:by] =~ /[+|-]?1/
render_text @link.points
end
here is how i am calling the method in my view:
<%= link_to('UP', modify_points_path(link, :by => 1), :remote => true) %>
however when i click on this UP link…. nothing happens. what should happen is link.points should increase by 1, however when i check in the console, my points are still at zero. am i creating the routes correctly?
I have always used something like this:
match ‘/modify_points’ => ‘link#modify_points’, :as => ‘modify_points’
Does that generate the route you want? What does rake routes show?