Class: ExtractsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ExtractsController
- Defined in:
- app/controllers/extracts_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /extracts POST /extracts.json.
-
#destroy ⇒ Object
DELETE /extracts/1 DELETE /extracts/1.json.
-
#edit ⇒ Object
GET /extracts/1/edit.
-
#extract_params ⇒ Object
private
Never trust parameters from the scary internet, only allow the white list through.
-
#index ⇒ Object
GET /extracts GET /extracts.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /extracts/new.
- #search ⇒ Object
-
#set_extract ⇒ Object
private
Use callbacks to share common setup or constraints between actions.
-
#show ⇒ Object
GET /extracts/1 GET /extracts/1.json.
-
#update ⇒ Object
PATCH/PUT /extracts/1 PATCH/PUT /extracts/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
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
GET /extracts/1/edit
24 25 |
# File 'app/controllers/extracts_controller.rb', line 24 def edit end |
#extract_params ⇒ Object (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 |
#index ⇒ Object
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 |
#list ⇒ Object
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 |
#new ⇒ Object
GET /extracts/new
19 20 21 |
# File 'app/controllers/extracts_controller.rb', line 19 def new @extract = Extract.new end |
#search ⇒ Object
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 |
#set_extract ⇒ Object (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.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /extracts/1 GET /extracts/1.json
15 16 |
# File 'app/controllers/extracts_controller.rb', line 15 def show end |
#update ⇒ Object
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 |