Class: CombinationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CombinationsController
- Defined in:
- app/controllers/combinations_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #combination_params ⇒ Object private
-
#create ⇒ Object
POST /combinations.json.
-
#destroy ⇒ Object
DELETE /combinations/1 DELETE /combinations/1.json.
-
#edit ⇒ Object
GET /combinations/1/edit.
-
#index ⇒ Object
GET /combinations.json.
-
#new ⇒ Object
GET /combinations/new.
- #set_combination ⇒ Object private
-
#show ⇒ Object
GET /combinations/123.json.
-
#update ⇒ Object
PATCH/PUT /combinations/1 PATCH/PUT /combinations/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 ProjectsHelper
#cumulative_gb_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification, #week_in_review_graphs
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
#combination_params ⇒ Object (private)
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/controllers/combinations_controller.rb', line 73 def combination_params p = ::Combination::APPLICABLE_RANKS.keys.inject(Hash.new){|hsh, r| hsh.merge "#{r}_taxon_name_relationship_attributes".to_sym => [:id, :_destroy] } params.require(:combination).permit( :verbatim_name, :verbatim_author, :year_of_publication, :source_id, *Combination::APPLICABLE_RANKS.keys.collect{ |r| "#{r}_id".to_sym}, p, origin_citation_attributes: [:id, :_destroy, :source_id, :pages], roles_attributes: [ :id, :_destroy, :type, :person_id, :position, person_attributes: [ :last_name, :first_name, :suffix, :prefix ] ], ) end |
#create ⇒ Object
POST /combinations.json
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/combinations_controller.rb', line 30 def create @combination = Combination.new(combination_params) respond_to do |format| if @combination.save format.html { redirect_to taxon_names_path, notice: 'Combination was successfully created.' } format.json { render :show, status: :created, location: @combination. } else format.html { render :new } format.json { render json: @combination.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /combinations/1 DELETE /combinations/1.json
59 60 61 62 63 64 65 |
# File 'app/controllers/combinations_controller.rb', line 59 def destroy @combination.destroy respond_to do |format| format.html { redirect_to taxon_names_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /combinations/1/edit
25 26 27 |
# File 'app/controllers/combinations_controller.rb', line 25 def edit redirect_to new_combination_task_path(params.require(:id)) end |
#index ⇒ Object
GET /combinations.json
7 8 9 |
# File 'app/controllers/combinations_controller.rb', line 7 def index @recent_objects = Combination.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(5) end |
#new ⇒ Object
GET /combinations/new
20 21 22 |
# File 'app/controllers/combinations_controller.rb', line 20 def new redirect_to new_combination_task_path(params.permit(:id)) end |
#set_combination ⇒ Object (private)
68 69 70 71 |
# File 'app/controllers/combinations_controller.rb', line 68 def set_combination @combination = Combination.with_project_id(sessions_current_project_id).find(params.require(:id)) @recent_object = @combination end |
#show ⇒ Object
GET /combinations/123.json
12 13 14 15 16 17 |
# File 'app/controllers/combinations_controller.rb', line 12 def show respond_to do |format| format.html { redirect_to taxon_name_path(params.require(:id)) } format.json { render :show, location: @combination. } end end |
#update ⇒ Object
PATCH/PUT /combinations/1 PATCH/PUT /combinations/1.json
45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/combinations_controller.rb', line 45 def update respond_to do |format| if @combination.update(combination_params) format.html { redirect_to url_for(@combination.), notice: 'Combination was successfully updated.' } format.json { render :show, status: :ok, location: @combination. } else format.html { render :edit } format.json { render json: @combination.errors, status: :unprocessable_entity } end end end |