Class: ExtractsController

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

#polymorphic_filter_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

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) create

POST /extracts POST /extracts.json



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/extracts_controller.rb', line 33

def create
  @extract = Extract.new(extract_params)

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

- (Object) destroy

DELETE /extracts/1 DELETE /extracts/1.json



63
64
65
66
67
68
69
# File 'app/controllers/extracts_controller.rb', line 63

def destroy
  @extract.destroy
  respond_to do |format|
    format.html { redirect_to extracts_url, notice: 'Extract was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /extracts/1/edit



24
25
# File 'app/controllers/extracts_controller.rb', line 24

def edit
end

- (Object) extract_params (private)

Never trust parameters from the scary internet, only allow the white list through.



86
87
88
# File 'app/controllers/extracts_controller.rb', line 86

def extract_params
  params.require(:extract).permit(:quantity_value, :quantity_unit, :concentration_value, :concentration_unit, :verbatim_anatomical_origin, :year_made, :month_made, :day_made)
end

- (Object) index

GET /extracts GET /extracts.json



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

def index
  @recent_objects = Extract.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
  render '/shared/data/all/index'
end

- (Object) list



27
28
29
# File 'app/controllers/extracts_controller.rb', line 27

def list
  @extracts = Extract.with_project_id(sessions_current_project_id).page(params[:page])
end

- (Object) new

GET /extracts/new



19
20
21
# File 'app/controllers/extracts_controller.rb', line 19

def new
  @extract = Extract.new
end

- (Object) search



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

def search
  if params[:id].blank?
    redirect_to extracts_path, notice: 'You must select an item from the list with a click or tab press before clicking show.'
  else
    redirect_to extract_path(params[:id])
  end
end

- (Object) set_extract (private)

Use callbacks to share common setup or constraints between actions.



81
82
83
# File 'app/controllers/extracts_controller.rb', line 81

def set_extract
  @extract = Extract.find(params[:id])
end

- (Object) show

GET /extracts/1 GET /extracts/1.json



15
16
# File 'app/controllers/extracts_controller.rb', line 15

def show
end

- (Object) update

PATCH/PUT /extracts/1 PATCH/PUT /extracts/1.json



49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/extracts_controller.rb', line 49

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