Class: BiologicalAssociationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BiologicalAssociationsController
- Defined in:
- app/controllers/biological_associations_controller.rb
Instance Method Summary collapse
- #api_index ⇒ Object
- #api_params ⇒ Object private
- #api_show ⇒ Object
- #biological_association_params ⇒ Object private
-
#create ⇒ Object
POST /biological_associations POST /biological_associations.json.
-
#destroy ⇒ Object
DELETE /biological_associations/1 DELETE /biological_associations/1.json.
-
#edit ⇒ Object
GET /biological_associations/1/edit.
- #filter_params ⇒ Object private
-
#index ⇒ Object
GET /biological_associations GET /biological_associations.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /biological_associations/new.
- #search ⇒ Object
- #set_biological_association ⇒ Object private
-
#show ⇒ Object
GET /biological_associations/1 GET /biological_associations/1.json.
-
#update ⇒ Object
PATCH/PUT /biological_associations/1 PATCH/PUT /biological_associations/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form
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
94 95 96 97 98 99 100 101 |
# File 'app/controllers/biological_associations_controller.rb', line 94 def api_index @biological_associations = Queries::BiologicalAssociation::Filter.new(api_params).all .where(project_id: sessions_current_project_id) .order('biological_associations.id') .page(params[:page]) .per(params[:per]) render '/biological_associations/api/v1/index' end |
#api_params ⇒ Object (private)
115 116 117 118 119 120 121 122 123 |
# File 'app/controllers/biological_associations_controller.rb', line 115 def api_params params.permit(:subject_global_id, :object_global_id, :any_global_id, :biological_relationship_id) # Shallow resource hack if !params[:collection_object_id].blank? && c = CollectionObject.where(project_id: sessions_current_project_id).find(params[:collection_object_id]) params[:any_global_id] = c.to_global_id.to_s end params end |
#api_show ⇒ Object
90 91 92 |
# File 'app/controllers/biological_associations_controller.rb', line 90 def api_show render '/biological_associations/api/v1/show' end |
#biological_association_params ⇒ Object (private)
129 130 131 132 133 134 135 136 137 138 |
# File 'app/controllers/biological_associations_controller.rb', line 129 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, :subject_global_id, :object_global_id, origin_citation_attributes: [:id, :_destroy, :source_id, :pages], citations_attributes: [:id, :is_original, :_destroy, :source_id, :pages, :citation_object_id, :citation_object_type], ) end |
#create ⇒ Object
POST /biological_associations POST /biological_associations.json
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/biological_associations_controller.rb', line 44 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 |
#destroy ⇒ Object
DELETE /biological_associations/1 DELETE /biological_associations/1.json
73 74 75 76 77 78 79 |
# File 'app/controllers/biological_associations_controller.rb', line 73 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 |
#edit ⇒ Object
GET /biological_associations/1/edit
35 36 |
# File 'app/controllers/biological_associations_controller.rb', line 35 def edit end |
#filter_params ⇒ Object (private)
105 106 107 108 109 110 111 112 113 |
# File 'app/controllers/biological_associations_controller.rb', line 105 def filter_params params.permit(:subject_global_id, :object_global_id, :any_global_id, :biological_relationship_id) # Shallow resource hack if !params[:collection_object_id].blank? && c = CollectionObject.where(project_id: sessions_current_project_id).find(params[:collection_object_id]) params[:any_global_id] = c.to_global_id.to_s end params end |
#index ⇒ Object
GET /biological_associations GET /biological_associations.json
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/biological_associations_controller.rb', line 8 def index respond_to do |format| format.html { @recent_objects = BiologicalAssociation.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' } format.json { @biological_associations = Queries::BiologicalAssociation::Filter .new(filter_params) .all .where(project_id: sessions_current_project_id) .page(params[:page] || 1).per(params[:per] || 500) } end end |
#list ⇒ Object
38 39 40 |
# File 'app/controllers/biological_associations_controller.rb', line 38 def list @biological_associations = BiologicalAssociation.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10) end |
#new ⇒ Object
GET /biological_associations/new
30 31 32 |
# File 'app/controllers/biological_associations_controller.rb', line 30 def new @biological_association = BiologicalAssociation.new end |
#search ⇒ Object
81 82 83 84 85 86 87 |
# File 'app/controllers/biological_associations_controller.rb', line 81 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 |
#set_biological_association ⇒ Object (private)
125 126 127 |
# File 'app/controllers/biological_associations_controller.rb', line 125 def set_biological_association @biological_association = BiologicalAssociation.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /biological_associations/1 GET /biological_associations/1.json
26 27 |
# File 'app/controllers/biological_associations_controller.rb', line 26 def show end |
#update ⇒ Object
PATCH/PUT /biological_associations/1 PATCH/PUT /biological_associations/1.json
59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/biological_associations_controller.rb', line 59 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 |