Class: DepictionsController

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

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#clear_project_and_user_variables, #digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #intercept_api, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #notice_user, #project_matches, #record_not_found, #set_project_and_user_variables, #set_project_from_params, #token_authenticate

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) create

POST /depictions POST /depictions.json



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/depictions_controller.rb', line 34

def create
  @depiction = Depiction.new(depiction_params)
  respond_to do |format|
    if @depiction.save
      format.html { redirect_to @depiction, notice: 'Depiction was successfully created.' }
      format.json { render :show, status: :created, location: @depiction }
    else
      format.html { render :new }
      format.json { render json: @depiction.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) depiction_params (private)

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



78
79
80
# File 'app/controllers/depictions_controller.rb', line 78

def depiction_params
 params.require(:depiction).permit(:depiction_object_id, :depiction_object_type, image_attributes: [:image_file])
end

- (Object) destroy

DELETE /depictions/1 DELETE /depictions/1.json



63
64
65
66
67
68
69
# File 'app/controllers/depictions_controller.rb', line 63

def destroy
  @depiction.destroy
  respond_to do |format|
    format.html { redirect_to depictions_url, notice: 'Depiction was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /depictions/1/edit



29
30
# File 'app/controllers/depictions_controller.rb', line 29

def edit
end

- (Object) index

GET /depictions GET /depictions.json



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

def index
  @recent_objects = Depiction.where(project_id: $project_id).order(updated_at: :desc).limit(10)
  render '/shared/data/all/index'
end

- (Object) list



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

def list
  @depictions = Depiction.where(project_id: $project_id).page(params[:page])
end

- (Object) new

GET /depictions/new



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

def new
  @depiction = Depiction.new
end

- (Object) set_depiction (private)

Use callbacks to share common setup or constraints between actions.



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

def set_depiction
  @depiction = Depiction.find(params[:id])
end

- (Object) show

GET /depictions/1 GET /depictions/1.json



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

def show
end

- (Object) update

PATCH/PUT /depictions/1 PATCH/PUT /depictions/1.json



49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/depictions_controller.rb', line 49

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