redirect_to(admin_conference_questions_path(:conference_id=>@conference.short_title),:alert=>"Sorry, you cannot edit global questions. Create a new one.")
redirect_to(admin_conference_questions_path(:conference_id=>@conference.short_title),:notice=>"Question '#{@question.title}' for #{@conference.short_title} successfully updated.")
else
redirect_to(admin_conference_questions_path(:conference_id=>@conference.short_title),:notice=>"Update of questions for #{@conference.short_title} failed.")
redirect_to(admin_conference_questions_path(:conference_id=>@conference.short_title),:notice=>"Questions for #{@conference.short_title} successfully updated.")
else
redirect_to(admin_conference_questions_path(:conference_id=>@conference.short_title),:notice=>"Update of questions for #{@conference.short_title} failed.")
end
end
# DELETE questions/1
defdestroy
ifhas_role?(current_user,"Admin")
@question=Question.find(params[:id])
# Do not delete global questions
if@question.global==false
# Delete question and its answers
begin
Question.transactiondo
@question.delete
@question.answers.eachdo|a|
a.delete
end
flash[:notice]="Deleted question: #{@question.title} and its answers: #{@question.answers.map{|a|a.title}.join','}"
end
rescueActiveRecord::RecordInvalid
flash[:error]="Could not delete question."
end
else
flash[:error]="You cannot delete global questions."
end
else
flash[:error]="You must be an admin to delete a question."