Skip to content

Instantly share code, notes, and snippets.

Created October 29, 2016 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d356b680d8723117dadb04ef45c44af7 to your computer and use it in GitHub Desktop.
Save anonymous/d356b680d8723117dadb04ef45c44af7 to your computer and use it in GitHub Desktop.
def toggle_quiz
if @quiz.update_attributes(active: params[:active])
respond_to do |format|
@ajax_status_text = if @quiz.active
"Successfully activated quiz"
else
"Successfully deactivated quiz."
end
@flash_status = if @quiz.active
"success"
else
"warning"
end
format.js
end
else
@ajax_status_text "Request Failed"
@flash_status = "error"
format.js
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment