Class: CombinationsController

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

#annotator_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, #whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) combination_params (private)



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

def combination_params
  params.require(:combination).permit(
    :verbatim_name, :source_id, 
    *Combination::APPLICABLE_RANKS.collect{|r| "#{r}_id".to_sym},
    origin_citation_attributes: [:id, :_destroy, :source_id, :pages],
  ) 
end

- (Object) create

POST /combinations.json



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/combinations_controller.rb', line 27

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.metamorphosize }
    else
      format.html { render :new }
      format.json { render json: @combination.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /combinations/1 DELETE /combinations/1.json



56
57
58
59
60
61
62
# File 'app/controllers/combinations_controller.rb', line 56

def destroy
  @combination.destroy
  respond_to do |format|
    format.html { redirect_to taxon_names_url }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /combinations/1/edit



22
23
24
# File 'app/controllers/combinations_controller.rb', line 22

def edit
  redirect_to new_combination_task_path(params.require(:id))
end

- (Object) index

GET /taxon_names.json



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

def index
  @recent_objects = Combination.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(5)
end

- (Object) new

GET /combinations/new



17
18
19
# File 'app/controllers/combinations_controller.rb', line 17

def new
  redirect_to new_combination_task_path(params.permit(:id))
end

- (Object) set_combination (private)



65
66
67
68
# File 'app/controllers/combinations_controller.rb', line 65

def set_combination
  @combination = Combination.with_project_id(sessions_current_project_id).find(params.require(:id))
  @recent_object = @combination 
end

- (Object) show

GET /combinations/123.json



13
14
# File 'app/controllers/combinations_controller.rb', line 13

def show
end

- (Object) update

PATCH/PUT /combinations/1 PATCH/PUT /combinations/1.json



42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/combinations_controller.rb', line 42

def update
  respond_to do |format|
    if @combination.update(combination_params)
      format.html { redirect_to url_for(@combination.metamorphosize), notice: 'Combination was successfully updated.' }
      format.json { render :show, status: :ok, location: @combination.metamorphosize }
    else
      format.html { render :edit }
      format.json { render json: @combination.errors, status: :unprocessable_entity }
    end
  end
end