Class: BiologicalAssociationsGraphsController

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



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

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

  render :json => data
end

- (Object) biological_associations_graph_params (private)



101
102
103
104
105
106
# File 'app/controllers/biological_associations_graphs_controller.rb', line 101

def biological_associations_graph_params
  params.require(:biological_associations_graph).permit(
    :name,
    origin_citation_attributes: [:id, :_destroy, :source_id] 
  )
end

- (Object) create

POST /biological_associations_graphs POST /biological_associations_graphs.json



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

def create
  @biological_associations_graph = BiologicalAssociationsGraph.new(biological_associations_graph_params)

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

- (Object) destroy

DELETE /biological_associations_graphs/1 DELETE /biological_associations_graphs/1.json



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

def destroy
  @biological_associations_graph.destroy
  respond_to do |format|
    format.html { redirect_to biological_associations_graphs_url, notice: 'Biological associations graph was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /biological_associations_graphs/1/edit



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

def edit
#    @biological_associations_graph.souce = Source.new if !@taxon_name.source
end

- (Object) index

GET /biological_associations_graphs GET /biological_associations_graphs.json



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

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

- (Object) list



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

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

- (Object) new

GET /biological_associations_graphs/new



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

def new
  @biological_associations_graph = BiologicalAssociationsGraph.new(origin_citation: Citation.new)
end

- (Object) search



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

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

- (Object) set_biological_associations_graph (private)



97
98
99
# File 'app/controllers/biological_associations_graphs_controller.rb', line 97

def set_biological_associations_graph
  @biological_associations_graph = BiologicalAssociationsGraph.find(params[:id])
end

- (Object) show

GET /biological_associations_graphs/1 GET /biological_associations_graphs/1.json



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

def show
end

- (Object) update

PATCH/PUT /biological_associations_graphs/1 PATCH/PUT /biological_associations_graphs/1.json



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

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