Class: CommonNamesController

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

#digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #project_matches, #record_not_found, #set_project_from_params

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Methods included from InterceptApi

#intercept_api, #token_authenticate

Instance Method Details

- (Object) common_name_params (private)



93
94
95
# File 'app/controllers/common_names_controller.rb', line 93

def common_name_params
  params.require(:common_name).permit(:name, :geographic_area_id, :otu_id, :language_id, :start_year, :end_year)
end

- (Object) create

POST /common_names POST /common_names.json



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/common_names_controller.rb', line 43

def create
  @common_name = CommonName.new(common_name_params)

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

- (Object) destroy

DELETE /common_names/1 DELETE /common_names/1.json



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

def destroy
  @common_name.destroy
  respond_to do |format|
    format.html { redirect_to common_names_url, notice: 'Common name was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /common_names/1/edit



34
35
# File 'app/controllers/common_names_controller.rb', line 34

def edit
end

- (Object) filter_params (private)



83
84
85
86
87
# File 'app/controllers/common_names_controller.rb', line 83

def filter_params
  params.permit(
    :name, :geographic_area_id, :otu_id, :language_id
  )
end

- (Object) index

GET /common_names GET /common_names.json



7
8
# File 'app/controllers/common_names_controller.rb', line 7

def index
end

- (Object) list



37
38
39
# File 'app/controllers/common_names_controller.rb', line 37

def list
  @common_names = CommonName.with_project_id(sessions_current_project_id).page(params[:page]) #.per(10) 
end

- (Object) new

GET /common_names/new



29
30
31
# File 'app/controllers/common_names_controller.rb', line 29

def new
  @common_name = CommonName.new
end

- (Object) set_common_name (private)



89
90
91
# File 'app/controllers/common_names_controller.rb', line 89

def set_common_name
  @common_name = CommonName.with_project_id(sessions_current_project_id).find(params[:id])
end

- (Object) show

GET /common_names/1 GET /common_names/1.json



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

def show
end

- (Object) update

PATCH/PUT /common_names/1 PATCH/PUT /common_names/1.json



59
60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/common_names_controller.rb', line 59

def update
  respond_to do |format|
    if @common_name.update(common_name_params)
      format.html { redirect_to @common_name, notice: 'Common name was successfully updated.' }
      format.json { render :show, status: :ok, location: @common_name }
    else
      format.html { render :edit }
      format.json { render json: @common_name.errors, status: :unprocessable_entity }
    end
  end
end