-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathcitation_topics_controller.rb
56 lines (49 loc) · 2.23 KB
/
citation_topics_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class CitationTopicsController < ApplicationController
include DataControllerConfiguration::ProjectDataControllerConfiguration
before_action :set_citation_topic, only: [:update, :destroy]
# POST /citation_topics
# POST /citation_topics.json
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
# PATCH/PUT /citation_topics/1
# PATCH/PUT /citation_topics/1.json
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
# DELETE /citation_topics/1
# DELETE /citation_topics/1.json
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
private
# Use callbacks to share common setup or constraints between actions.
def set_citation_topic
@citation_topic = CitationTopic.with_project_id(sessions_current_project_id).find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def citation_topic_params
params.require(:citation_topic).permit(:citation_id, :topic_id)
end
end