【发布时间】:2014-02-13 23:52:37
【问题描述】:
这是我的看法:(show.html.erb)
<%=link_to vote_for, vote_for_question_path(@question), :remote => true%>
这是链接在 question_controller 中调用的操作:
def vote_for
@quest_vote_for = Question.find(params[:id])
current_user.vote_exclusively_for(@quest_vote_for)
@total_vote = current_user.total_votes
respond_to do |format|
format.js{}
format.html
end
end
我想要的是在单击链接后更新 show.html.erb 的内容。 (我正在使用 ajax (remote=>true))。 show.html.page 应该使用@total_vote 的新值更新自身。
我该怎么做?
【问题讨论】:
标签: ruby-on-rails ajax ruby-on-rails-3 ruby-on-rails-4