Class: ObservationMatrixRowItemsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/observation_matrix_row_items_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 included from DataControllerConfiguration::ProjectDataControllerConfiguration

#polymorphic_filter_params

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, #whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) create

POST /matrix_row_items POST /matrix_row_items.json



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 35

def create
  @observation_matrix_row_item = ObservationMatrixRowItem.new(observation_matrix_row_item_params)

  respond_to do |format|
    if @observation_matrix_row_item.save
      format.html { redirect_to url_for(@observation_matrix_row_item.metamorphosize),
                                notice: 'Matrix row item was successfully created.' }
      format.json { render :show, status: :created, location: @observation_matrix_row_item }
    else
      format.html { render :new }
      format.json { render json: @observation_matrix_row_item.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /matrix_row_items/1 DELETE /matrix_row_items/1.json



67
68
69
70
71
72
73
74
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 67

def destroy
  @observation_matrix_row_item.destroy!
  respond_to do |format|
    format.html { redirect_to observation_matrix_row_items_url,
                              notice: 'Matrix row item was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /matrix_row_items/1/edit



30
31
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 30

def edit
end

- (Object) index

GET /matrix_row_items GET /matrix_row_items.json



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

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

- (Object) list



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

def list
  @observation_matrix_row_items = ObservationMatrixRow.with_project_id(sessions_current_project_id)
                                    .page(params[:page])
end

- (Object) new

GET /matrix_row_items/new



25
26
27
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 25

def new
  @observation_matrix_row_item = ObservationMatrixRowItem.new
end

- (Object) observation_matrix_row_item_params (private)



81
82
83
84
85
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 81

def observation_matrix_row_item_params
  params.require(:observation_matrix_row_item).permit(:observation_matrix_id, :type,
                                                      :collection_object_id, :otu_id,
                                                      :controlled_vocabulary_term_id, :type)
end

- (Object) set_observation_matrix_row_item (private)



77
78
79
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 77

def set_observation_matrix_row_item
  @observation_matrix_row_item = ObservationMatrixRowItem.find(params[:id])
end

- (Object) show

GET /matrix_row_items/1 GET /matrix_row_items/1.json



16
17
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 16

def show
end

- (Object) update

PATCH/PUT /matrix_row_items/1 PATCH/PUT /matrix_row_items/1.json



52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/observation_matrix_row_items_controller.rb', line 52

def update
  respond_to do |format|
    if @observation_matrix_row_item.update(observation_matrix_row_item_params)
      format.html { redirect_to url_for(@observation_matrix_row_item.metamorphosize),
                                notice: 'Matrix row item was successfully updated.' }
      format.json { render :show, status: :ok, location: @observation_matrix_row_item }
    else
      format.html { render :edit }
      format.json { render json: @observation_matrix_row_item.errors, status: :unprocessable_entity }
    end
  end
end