删除单选题后页面数据的删除,增加删除题目的路由及相关方法

This commit is contained in:
sw 2015-01-15 17:15:29 +08:00
parent 870f9bba98
commit 3fab26214f
4 changed files with 21 additions and 1 deletions

View File

@ -117,6 +117,21 @@ class PollController < ApplicationController
a = 1
end
#删除单选题
def delete_poll_question
@poll_question = PollQuestion.find params[:poll_question]
poll_questions = @poll_question.poll.poll_questions.where("question_number > #{@poll_question.question_number}")
poll_questions.each do |question|
question.question_number -= 1
question.save
end
if @poll_question && @poll_question.destroy
respond_to do |format|
format.js
end
end
end
private
def find_poll_and_course
@poll = Poll.find params[:id]

View File

@ -9,7 +9,8 @@
<%end%>
</div>
<a class="ur_icon_de" title="删除" onclick=""></a>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
<div class="cl"></div>
<div class="ur_inputs">

View File

@ -0,0 +1 @@
$("#poll_questions_<%= @poll_question.id%>").remove();

View File

@ -64,6 +64,9 @@ RedmineApp::Application.routes.draw do
post 'create_poll_question'
post 'update_poll_question'
end
collection do
delete 'delete_poll_question'
end
end
resources :contest_notification