Class: CharacterStatesController

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

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

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

#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form

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

#annotationsObject

TODO: remove GET /character_states/annotations.json


73
74
75
76
# File 'app/controllers/character_states_controller.rb', line 73

def annotations
  @object = @character_state
  render '/shared/data/all/annotations'
end

#character_state_paramsObject (private)


83
84
85
# File 'app/controllers/character_states_controller.rb', line 83

def character_state_params
  params.require(:character_state).permit(:name, :key_name, :description_name, :label, :descriptor_id, :position)
end

#createObject

POST /character_states POST /character_states.json


29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/character_states_controller.rb', line 29

def create
  @character_state = CharacterState.new(character_state_params)

  respond_to do |format|
    if @character_state.save
      format.html { redirect_to @character_state, notice: 'Character state was successfully created.' }
      format.json { render :show, status: :created, location: @character_state }
    else
      format.html { render :new }
      format.json { render json: @character_state.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /character_states/1 DELETE /character_states/1.json


59
60
61
62
63
64
65
# File 'app/controllers/character_states_controller.rb', line 59

def destroy
  @character_state.destroy
  respond_to do |format|
    format.html { redirect_to character_states_url, notice: 'Character state was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /character_states/1/edit


24
25
# File 'app/controllers/character_states_controller.rb', line 24

def edit
end

#indexObject

GET /character_states GET /character_states.json


8
9
10
11
# File 'app/controllers/character_states_controller.rb', line 8

def index
  @recent_objects = CharacterState.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
  render '/shared/data/all/index'
end

#listObject


67
68
69
# File 'app/controllers/character_states_controller.rb', line 67

def list
  @character_states = CharacterState.with_project_id(sessions_current_project_id).page(params[:page])
end

#newObject

GET /character_states/new


19
20
21
# File 'app/controllers/character_states_controller.rb', line 19

def new
  @character_state = CharacterState.new
end

#set_character_stateObject (private)


79
80
81
# File 'app/controllers/character_states_controller.rb', line 79

def set_character_state
  @character_state = CharacterState.where(project_id: sessions_current_project_id).find(params[:id])
end

#showObject

GET /character_states/1 GET /character_states/1.json


15
16
# File 'app/controllers/character_states_controller.rb', line 15

def show
end

#updateObject

PATCH/PUT /character_states/1 PATCH/PUT /character_states/1.json


45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/character_states_controller.rb', line 45

def update
  respond_to do |format|
    if @character_state.update(character_state_params)
      format.html { redirect_to @character_state, notice: 'Character state was successfully updated.' }
      format.json { render :show, status: :ok, location: @character_state }
    else
      format.html { render :edit }
      format.json { render json: @character_state.errors, status: :unprocessable_entity }
    end
  end
end