Class: BiologicalRelationshipsController

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

#annotator_params

Methods inherited from ApplicationController

#digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #project_matches, #record_not_found, #set_project_from_params

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Methods included from InterceptApi

#intercept_api, #token_authenticate

Instance Method Details

- (Object) autocomplete



86
87
88
# File 'app/controllers/biological_relationships_controller.rb', line 86

def autocomplete
  @biological_relationships = Queries::BiologicalRelationship::Autocomplete.new( params.require(:term), project_id: sessions_current_project_id).all
end

- (Object) biological_relationship_params (private)



104
105
106
107
108
109
110
# File 'app/controllers/biological_relationships_controller.rb', line 104

def biological_relationship_params
  params.require(:biological_relationship).permit(
    :name, :inverted_name, :is_transitive, :is_reflexive, 
    :created_by_id, :updated_by_id, :project_id,
    origin_citation_attributes: [:id, :_destroy, :source_id, :pages]
  )
end

- (Object) create

POST /biological_relationships POST /biological_relationships.json



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/biological_relationships_controller.rb', line 40

def create
  @biological_relationship = BiologicalRelationship.new(biological_relationship_params)

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

- (Object) destroy

DELETE /biological_relationships/1 DELETE /biological_relationships/1.json



70
71
72
73
74
75
76
# File 'app/controllers/biological_relationships_controller.rb', line 70

def destroy
  @biological_relationship.destroy
  respond_to do |format|
    format.html { redirect_to biological_relationships_url, notice: 'Biological relationship was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /biological_relationships/1/edit



31
32
# File 'app/controllers/biological_relationships_controller.rb', line 31

def edit
end

- (Object) filter_sql (private)



96
97
98
# File 'app/controllers/biological_relationships_controller.rb', line 96

def filter_sql
  {}
end

- (Object) index

GET /biological_relationships GET /biological_relationships.json



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/biological_relationships_controller.rb', line 8

def index
  respond_to do |format|
    format.html do
      @recent_objects = BiologicalRelationship.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
      render '/shared/data/all/index'
    end
    format.json {
      @biological_relationships = BiologicalRelationship.where(filter_sql).with_project_id(sessions_current_project_id).order(:name)
    }
  end
end

- (Object) list



34
35
36
# File 'app/controllers/biological_relationships_controller.rb', line 34

def list
  @biological_relationships = BiologicalRelationship.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10)
end

- (Object) new

GET /biological_relationships/new



26
27
28
# File 'app/controllers/biological_relationships_controller.rb', line 26

def new
  @biological_relationship = BiologicalRelationship.new
end

- (Object) search



78
79
80
81
82
83
84
# File 'app/controllers/biological_relationships_controller.rb', line 78

def search
  if params[:id].blank?
    redirect_to biological_relationships_path, notice: 'You must select an item from the list with a click or tab press before clicking show.'
  else
    redirect_to biological_relationship_path(params[:id])
  end
end

- (Object) select_options



90
91
92
# File 'app/controllers/biological_relationships_controller.rb', line 90

def select_options
  @biological_relationships = BiologicalRelationship.select_optimized(sessions_current_user_id, sessions_current_project_id)
end

- (Object) set_biological_relationship (private)



100
101
102
# File 'app/controllers/biological_relationships_controller.rb', line 100

def set_biological_relationship
  @biological_relationship = BiologicalRelationship.find(params[:id])
end

- (Object) show

GET /biological_relationships/1 GET /biological_relationships/1.json



22
23
# File 'app/controllers/biological_relationships_controller.rb', line 22

def show
end

- (Object) update

PATCH/PUT /biological_relationships/1 PATCH/PUT /biological_relationships/1.json



56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/biological_relationships_controller.rb', line 56

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