javascript - Is there a way to call a Rails 3 function from a link_to tag, using :remote => true? -
in rails 3 app, have list of questions. each question has "question number" designates order in table/list. i'm trying implement "move up" link decrement question's number move in list (1 @ top), , increment number of question had number.
i'm stuck on how call rails function, either in controller or model, question table view. ideally want like:
<%= link_to 'move up', question.moveup(question.id), :remote => true, :update => "questions_table" %>
but doesn't seem possible combination of "onclick", "remote_function", etc i've looked into.
i've tried call function in controller url, this:
<%= link_to "move up", :url => {:controller => "questions", :action => "moveup"}, :remote => true %>
but keeps searching url appending edit?url[controller]=questions&url[action]=moveup not want. there straightforward way call function in rails 3 model or controller link, remotely?
thanks much!
try without :url
hash
<%= link_to "move up", {:controller => "questions", :action => "moveup"}, :remote => true %>
Comments
Post a Comment