search is now saved asynchron and without a form which caused some redirection through searches_controller

added asynchronous save of search, removed searches_controller,
This commit is contained in:
Thomas Hille
2017-03-21 14:37:32 +01:00
parent 4a9867b81b
commit b05bb27ed9
7 changed files with 28 additions and 45 deletions

View File

@ -6,7 +6,7 @@ class ExercisesController < ApplicationController
before_action :handle_file_uploads, only: [:create, :update]
before_action :set_execution_environments, only: [:create, :edit, :new, :update]
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :working_times, :intervention, :run, :statistics, :submit, :reload]
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :working_times, :intervention, :search, :run, :statistics, :submit, :reload]
before_action :set_external_user, only: [:statistics]
before_action :set_file_types, only: [:create, :edit, :new, :update]
before_action :set_course_token, only: [:implement]
@ -223,7 +223,17 @@ class ExercisesController < ApplicationController
else
render(json: {success: 'false', error: "undefined intervention #{params[:intervention_type]}"})
end
end
def search
search_text = params[:search_text]
search = Search.new(user: current_user, exercise: @exercise, search: search_text)
begin search.save
render(json: {success: 'true'})
rescue
render(json: {success: 'false', error: "could not save search: #{$!}"})
end
end
def index