Class: BiologicalAssociationsController

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

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) autocomplete



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/controllers/biological_associations_controller.rb', line 79

def autocomplete
  @biological_associations = BiologicalAssociation.find_for_autocomplete(params.merge(project_id: sessions_current_project_id))
  data = @biological_associations.collect do |t|
    {id: t.id,
     label: ApplicationController.helpers.biological_association_tag(t),
     response_values: {
         params[:method] => t.id
     },
     label_html: ApplicationController.helpers.biological_association_autocomplete_selected_tag(t)
    }
  end

  render :json => data
end

- (Object) biological_association_params (private)

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



101
102
103
# File 'app/controllers/biological_associations_controller.rb', line 101

def biological_association_params
  params.require(:biological_association).permit(:biological_relationship_id, :biological_association_subject_id, :biological_association_subject_type, :biological_association_object_id, :biological_association_object_type, :created_by_id, :updated_by_id, :project_id)
end

- (Object) create

POST /biological_associations POST /biological_associations.json



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

def create
  @biological_association = BiologicalAssociation.new(biological_association_params)

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

- (Object) destroy

DELETE /biological_associations/1 DELETE /biological_associations/1.json



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

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

- (Object) edit

GET /biological_associations/1/edit



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

def edit
end

- (Object) index

GET /biological_associations GET /biological_associations.json



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

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

- (Object) list



27
28
29
# File 'app/controllers/biological_associations_controller.rb', line 27

def list
  @biological_associations = BiologicalAssociation.with_project_id($project_id).order(:id).page(params[:page]) #.per(10)
end

- (Object) new

GET /biological_associations/new



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

def new
  @biological_association = BiologicalAssociation.new
end

- (Object) search



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

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

- (Object) set_biological_association (private)

Use callbacks to share common setup or constraints between actions.



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

def set_biological_association
  @biological_association = BiologicalAssociation.find(params[:id])
end

- (Object) show

GET /biological_associations/1 GET /biological_associations/1.json



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

def show
end

- (Object) update

PATCH/PUT /biological_associations/1 PATCH/PUT /biological_associations/1.json



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

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