Class: ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Includes:
AuthenticatedSystem
Defined in:
app/controllers/application_controller.rb

Overview

Filters added to this controller apply to all controllers in the application. Likewise, all the methods added will be available for all controllers.

Direct Known Subclasses

Admin::BaitLibraries::BaitLibrarySuppliersController, Admin::BaitLibraries::BaitLibraryTypesController, Admin::BaitLibrariesController, Admin::CustomTextsController, Admin::DelayedJobsController, Admin::FacultySponsorsController, Admin::PlatePurposesController, Admin::PrimerPanelsController, Admin::ProgramsController, Admin::ProjectsController, Admin::RobotPropertiesController, Admin::RobotsController, Admin::Roles::UsersController, Admin::RolesController, Admin::StudiesController, Admin::UsersController, AdminController, Aker::JobsController, Api::V2::Aker::JobsController, AssetAuditsController, AssetsController, BarcodePrintersController, Batches::CommentsController, Batches::RequestsController, BatchesController, BillingReportsController, BulkSubmissionExcel::DownloadsController, BulkSubmissionsController, DocumentsController, EventsController, GelsController, GetYourQcCompletedTubesHereController, HealthController, HomesController, LabSearchesController, Labware::CommentsController, LabwareController, LabwhereReceptionsController, LocationReportsController, MachineBarcodesController, MeetingController, NpgActions::AssetsController, OrdersController, ParentsController, PhiX::SpikedBuffersController, PhiX::StocksController, PhiXesController, PipelinesController, PlateSummariesController, PlateTemplatesController, PlatesController, PoolingsController, ProjectsController, QcFilesController, QcReportsController, Receptacles::CommentsController, ReceptaclesController, ReceptionsController, ReferenceGenomesController, Requests::CommentsController, RequestsController, RobotVerificationsController, SampleLogisticsController, SampleManifestUploadWithTagSequencesController, Samples::CommentsController, Samples::StudiesController, SamplesController, Sdb::BaseController, SearchesController, SequenomQcPlatesController, SessionsController, StockAssetsController, StockStampersController, Studies::AssetGroupsController, Studies::CommentsController, Studies::DocumentsController, Studies::EventsController, Studies::InformationController, Studies::SampleRegistrationController, Studies::SamplesController, StudiesController, StudyReportsController, SubmissionsController, TagGroupsController, TagLayoutTemplatesController, TagSubstitutionsController, TagsController, UatActionsController, UserQueriesController, UsersController, UuidsController, WorkflowsController

Instance Method Summary collapse

Instance Method Details

#block_api_access(message = nil, format = :xml) ⇒ Object


49
50
51
52
53
# File 'app/controllers/application_controller.rb', line 49

def block_api_access(message = nil, format = :xml)
  content = { error: 'Unsupported API access' }
  content[:message] = message unless message.nil?
  { format => content.send("to_#{format}".to_sym, root: :errors), :status => 406 }
end

#clean_params_from_check(object) ⇒ Object

clean parameters hash from :check generated by checktext_field fields.


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/application_controller.rb', line 25

def clean_params_from_check(object)
  return object unless object.is_a?(Hash)

  new_hash = object.class.new
  to_nil = []
  object.each do |k, v|
    if k == 'check' and v.is_a?(Hash)
      v.each do |k, v|
        to_nil << k unless v == 'true'
      end
    else # normal
      new_hash[k] = clean_params_from_check(v)
    end
  end

  to_nil.each do |k|
    new_hash[k] = nil
  end

  new_hash
end

#evil_parameter_hack!Object


66
67
68
69
70
71
72
# File 'app/controllers/application_controller.rb', line 66

def evil_parameter_hack!
  # WARNING! This hack is purely in place while we manually update ALL our
  # existing controllers to support Strong Parameters. It should under
  # not circumstances get used in new code, and should be removed from
  # existing controllers as soon as humanly possible.
  params.permit!
end

#extract_header_infoObject


55
56
57
58
# File 'app/controllers/application_controller.rb', line 55

def extract_header_info
  exclude_nested_resource = request.headers['HTTP_EXCLUDE_NESTED_RESOURCE'] || params[:exclude_nested_resource]
  @exclude_nested_resource = exclude_nested_resource && exclude_nested_resource.to_s.casecmp('true').zero?
end

#set_cache_disabled!Object


60
61
62
63
64
# File 'app/controllers/application_controller.rb', line 60

def set_cache_disabled!
  response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
  response.headers['Pragma'] = 'no-cache'
  response.headers['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT'
end