Class: LabelsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- LabelsController
- Defined in:
- app/controllers/labels_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /labels POST /labels.json.
-
#destroy ⇒ Object
DELETE /labels/1 DELETE /labels/1.json.
-
#edit ⇒ Object
GET /labels/1/edit.
- #filter_params ⇒ Object private
-
#index ⇒ Object
GET /labels GET /labels.json.
- #label_params ⇒ Object private
- #list ⇒ Object
-
#new ⇒ Object
GET /labels/new.
- #set_label ⇒ Object private
-
#show ⇒ Object
GET /labels/1 GET /labels/1.json.
-
#update ⇒ Object
PATCH/PUT /labels/1 PATCH/PUT /labels/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#create ⇒ Object
POST /labels POST /labels.json
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/labels_controller.rb', line 45 def create @label = Label.new(label_params) respond_to do |format| if @label.save format.html { redirect_to @label, notice: 'Label was successfully created.' } format.json { render :show, status: :created, location: @label. } else format.html { render :new } format.json { render json: @label.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /labels/1 DELETE /labels/1.json
75 76 77 78 79 80 81 |
# File 'app/controllers/labels_controller.rb', line 75 def destroy @label.destroy respond_to do |format| format.html { redirect_to labels_url, notice: 'Label was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /labels/1/edit
36 37 |
# File 'app/controllers/labels_controller.rb', line 36 def edit end |
#filter_params ⇒ Object (private)
89 90 91 |
# File 'app/controllers/labels_controller.rb', line 89 def filter_params params.permit(:label_object_id, :label_object_type) end |
#index ⇒ Object
GET /labels GET /labels.json
8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/labels_controller.rb', line 8 def index respond_to do |format| format.html do @recent_objects = Label.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json { @labels = Label.where(filter_params).with_project_id(sessions_current_project_id) } end end |
#label_params ⇒ Object (private)
93 94 95 96 97 98 99 |
# File 'app/controllers/labels_controller.rb', line 93 def label_params params.require(:label).permit( :text, :total, :style, :is_copy_edited, :is_printed, :type, :label_object_id, :label_object_type, :annotated_global_entity ) end |
#list ⇒ Object
20 21 22 23 |
# File 'app/controllers/labels_controller.rb', line 20 def list @labels = Label.with_project_id(sessions_current_project_id).page(params[:page]) @recent_object = @label end |
#new ⇒ Object
GET /labels/new
31 32 33 |
# File 'app/controllers/labels_controller.rb', line 31 def new @label = Label.new end |
#set_label ⇒ Object (private)
85 86 87 |
# File 'app/controllers/labels_controller.rb', line 85 def set_label @label = Label.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /labels/1 GET /labels/1.json
27 28 |
# File 'app/controllers/labels_controller.rb', line 27 def show end |
#update ⇒ Object
PATCH/PUT /labels/1 PATCH/PUT /labels/1.json
61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/labels_controller.rb', line 61 def update respond_to do |format| if @label.update(label_params) format.html { redirect_to @label, notice: 'Label was successfully updated.' } format.json { render :show, status: :ok, location: @label. } else format.html { render :edit } format.json { render json: @label.errors, status: :unprocessable_entity } end end end |