Class: BiologicalRelationshipsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BiologicalRelationshipsController
- Defined in:
- app/controllers/biological_relationships_controller.rb
Instance Method Summary collapse
- #api_index ⇒ Object
- #autocomplete ⇒ Object
- #biological_relationship_params ⇒ Object private
-
#create ⇒ Object
POST /biological_relationships POST /biological_relationships.json.
-
#destroy ⇒ Object
DELETE /biological_relationships/1 DELETE /biological_relationships/1.json.
-
#edit ⇒ Object
GET /biological_relationships/1/edit.
- #filter_sql ⇒ Object private
-
#index ⇒ Object
GET /biological_relationships GET /biological_relationships.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /biological_relationships/new.
- #search ⇒ Object
- #select_options ⇒ Object
- #set_biological_relationship ⇒ Object private
-
#show ⇒ Object
GET /biological_relationships/1 GET /biological_relationships/1.json.
-
#update ⇒ Object
PATCH/PUT /biological_relationships/1 PATCH/PUT /biological_relationships/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#api_index ⇒ Object
20 21 22 23 |
# File 'app/controllers/biological_relationships_controller.rb', line 20 def api_index @biological_relationships = BiologicalRelationship.with_project_id(sessions_current_project_id).order(:name) render '/biological_relationships/api/v1/index' end |
#autocomplete ⇒ Object
91 92 93 |
# File 'app/controllers/biological_relationships_controller.rb', line 91 def autocomplete @biological_relationships = Queries::BiologicalRelationship::Autocomplete.new( params.require(:term), project_id: sessions_current_project_id).all end |
#biological_relationship_params ⇒ Object (private)
109 110 111 112 113 114 115 |
# File 'app/controllers/biological_relationships_controller.rb', line 109 def biological_relationship_params params.require(:biological_relationship).permit( :name, :inverted_name, :is_transitive, :is_reflexive, :definition, biological_relationship_types_attributes: [:id, :_destroy, :type, :biological_property_id], origin_citation_attributes: [:id, :_destroy, :source_id, :pages] ) end |
#create ⇒ Object
POST /biological_relationships POST /biological_relationships.json
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/biological_relationships_controller.rb', line 45 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 |
#destroy ⇒ Object
DELETE /biological_relationships/1 DELETE /biological_relationships/1.json
75 76 77 78 79 80 81 |
# File 'app/controllers/biological_relationships_controller.rb', line 75 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 |
#edit ⇒ Object
GET /biological_relationships/1/edit
36 37 |
# File 'app/controllers/biological_relationships_controller.rb', line 36 def edit end |
#filter_sql ⇒ Object (private)
101 102 103 |
# File 'app/controllers/biological_relationships_controller.rb', line 101 def filter_sql {} end |
#index ⇒ Object
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.with_project_id(sessions_current_project_id).order(:name) } end end |
#list ⇒ Object
39 40 41 |
# File 'app/controllers/biological_relationships_controller.rb', line 39 def list @biological_relationships = BiologicalRelationship.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10) end |
#new ⇒ Object
GET /biological_relationships/new
31 32 33 |
# File 'app/controllers/biological_relationships_controller.rb', line 31 def new @biological_relationship = BiologicalRelationship.new end |
#search ⇒ Object
83 84 85 86 87 88 89 |
# File 'app/controllers/biological_relationships_controller.rb', line 83 def search if params[:id].blank? redirect_to biological_relationships_path, alert: '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 |
#select_options ⇒ Object
95 96 97 |
# File 'app/controllers/biological_relationships_controller.rb', line 95 def @biological_relationships = BiologicalRelationship.select_optimized(sessions_current_user_id, sessions_current_project_id) end |
#set_biological_relationship ⇒ Object (private)
105 106 107 |
# File 'app/controllers/biological_relationships_controller.rb', line 105 def set_biological_relationship @biological_relationship = BiologicalRelationship.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /biological_relationships/1 GET /biological_relationships/1.json
27 28 |
# File 'app/controllers/biological_relationships_controller.rb', line 27 def show end |
#update ⇒ Object
PATCH/PUT /biological_relationships/1 PATCH/PUT /biological_relationships/1.json
61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/biological_relationships_controller.rb', line 61 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 |