Class: CitationTopicsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/citation_topics_controller.rb

Constant Summary

Constants included from ProjectsHelper

ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods included from RedirectHelper

#destroy_redirect

Methods included from RequestType

#json_request?

Methods included from LogRecent

#log_user_recent_route

Methods included from Cookies

#digest_cookie, #digested_cookie_exists?

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#cumulative_gb_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification

Methods included from Api::Intercept

#intercept_api

Methods included from TokenAuthentication

#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate

Instance Method Details

#citation_topic_paramsObject (private)

Never trust parameters from the scary internet, only allow the white list through.



53
54
55
# File 'app/controllers/citation_topics_controller.rb', line 53

def citation_topic_params
  params.require(:citation_topic).permit(:citation_id, :topic_id)
end

#createObject

POST /citation_topics POST /citation_topics.json



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/citation_topics_controller.rb', line 8

def create
  @citation_topic = CitationTopic.new(citation_topic_params)

  respond_to do |format|
    if @citation_topic.save
      format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Citation topic was successfully updated.')}
      format.json { render json: @citation_topic, status: :created, location: @citation_topic }
    else
      format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Citation topic was NOT successfully updated.')}
      format.json { render json: @citation_topic.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /citation_topics/1 DELETE /citation_topics/1.json



38
39
40
41
42
43
44
# File 'app/controllers/citation_topics_controller.rb', line 38

def destroy
  @citation_topic.destroy
  respond_to do |format|
    format.html { destroy_redirect @citation_topic, notice: 'Citation topic was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#set_citation_topicObject (private)

Use callbacks to share common setup or constraints between actions.



48
49
50
# File 'app/controllers/citation_topics_controller.rb', line 48

def set_citation_topic
  @citation_topic = CitationTopic.with_project_id(sessions_current_project_id).find(params[:id])
end

#updateObject

PATCH/PUT /citation_topics/1 PATCH/PUT /citation_topics/1.json



24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/citation_topics_controller.rb', line 24

def update
  respond_to do |format|
    if @citation_topic.update(citation_topic_params)
      format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Citation topic was successfully updated.')}
      format.json { render json: @citation_topic, status: :ok, location: @citation_topic }
    else
      format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Citation topic was NOT successfully updated.')}
      format.json { render json: @citation_topic.errors, status: :unprocessable_entity }
    end
  end
end