Class: PreparationTypesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PreparationTypesController
- Defined in:
- app/controllers/preparation_types_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
-
#create ⇒ Object
POST /preparation_types POST /preparation_types.json.
-
#destroy ⇒ Object
DELETE /preparation_types/1 DELETE /preparation_types/1.json.
-
#download ⇒ Object
GET /preparation_types/download.
-
#edit ⇒ Object
GET /preparation_types/1/edit.
-
#index ⇒ Object
GET /preparation_types GET /preparation_types.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /preparation_types/new.
-
#preparation_type_params ⇒ Object
private
Never trust parameters from the scary internet, only allow the white list through.
- #search ⇒ Object
-
#set_preparation_type ⇒ Object
private
Use callbacks to share common setup or constraints between actions.
-
#show ⇒ Object
GET /preparation_types/1 GET /preparation_types/1.json.
-
#update ⇒ Object
PATCH/PUT /preparation_types/1 PATCH/PUT /preparation_types/1.json.
Methods included from DataControllerConfiguration::SharedDataControllerConfiguration
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
#create ⇒ Object
POST /preparation_types POST /preparation_types.json
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/preparation_types_controller.rb', line 35 def create @preparation_type = PreparationType.new(preparation_type_params) respond_to do |format| if @preparation_type.save format.html { redirect_to @preparation_type, notice: "Preparation type '#{@preparation_type.name}' was successfully created." } format.json { render action: 'show', status: :created, location: @preparation_type } else format.html { render action: 'new' } format.json { render json: @preparation_type.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /preparation_types/1 DELETE /preparation_types/1.json
65 66 67 68 69 70 71 |
# File 'app/controllers/preparation_types_controller.rb', line 65 def destroy @preparation_type.destroy respond_to do |format| format.html { redirect_to preparation_types_url } format.json { head :no_content } end end |
#download ⇒ Object
GET /preparation_types/download
86 87 88 89 90 |
# File 'app/controllers/preparation_types_controller.rb', line 86 def download send_data(Export::CSV.generate_csv(PreparationType.all), type: 'text', filename: "preparation_types_#{DateTime.now}.tsv") end |
#edit ⇒ Object
GET /preparation_types/1/edit
30 31 |
# File 'app/controllers/preparation_types_controller.rb', line 30 def edit end |
#index ⇒ Object
GET /preparation_types GET /preparation_types.json
8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/preparation_types_controller.rb', line 8 def index respond_to do |format| @preparation_types = PreparationType.all format.html do @recent_objects = PreparationType.order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json {} end end |
#list ⇒ Object
73 74 75 |
# File 'app/controllers/preparation_types_controller.rb', line 73 def list @preparation_types = PreparationType.order(:id).page(params[:page]) #.per(10) #.per(3) end |
#new ⇒ Object
GET /preparation_types/new
25 26 27 |
# File 'app/controllers/preparation_types_controller.rb', line 25 def new @preparation_type = PreparationType.new end |
#preparation_type_params ⇒ Object (private)
Never trust parameters from the scary internet, only allow the white list through.
117 118 119 |
# File 'app/controllers/preparation_types_controller.rb', line 117 def preparation_type_params params.require(:preparation_type).permit(:name, :definition) end |
#search ⇒ Object
77 78 79 80 81 82 83 |
# File 'app/controllers/preparation_types_controller.rb', line 77 def search if params[:id].blank? redirect_to preparation_type_path, alert: 'You must select an item from the list with a click or tab press before clicking show.' else redirect_to preparation_type_path(params[:id]) end end |
#set_preparation_type ⇒ Object (private)
Use callbacks to share common setup or constraints between actions.
111 112 113 114 |
# File 'app/controllers/preparation_types_controller.rb', line 111 def set_preparation_type @preparation_type = PreparationType.find(params[:id]) @recent_object = @preparation_type end |
#show ⇒ Object
GET /preparation_types/1 GET /preparation_types/1.json
21 22 |
# File 'app/controllers/preparation_types_controller.rb', line 21 def show end |
#update ⇒ Object
PATCH/PUT /preparation_types/1 PATCH/PUT /preparation_types/1.json
51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/preparation_types_controller.rb', line 51 def update respond_to do |format| if @preparation_type.update(preparation_type_params) format.html { redirect_to @preparation_type, notice: 'Preparation type was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @preparation_type.errors, status: :unprocessable_entity } end end end |