Class: SupplejackApi::RecordsController
Instance Method Summary
collapse
#authenticate_admin!, #authenticate_user!, #current_user, #find_user_set
Instance Method Details
#default_serializer_options ⇒ Object
This options are merged with the serializer options. Which will allow the serializer to know which fields to render for a specific request
54
55
56
57
58
59
60
|
# File 'app/controllers/supplejack_api/records_controller.rb', line 54
def default_serializer_options
default_options = {}
@search ||= SupplejackApi::RecordSearch.new(params)
default_options[:fields] = @search.field_list if @search.field_list.present?
default_options[:groups] = @search.group_list if @search.group_list.present?
default_options
end
|
#index ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/supplejack_api/records_controller.rb', line 17
def index
@search = SupplejackApi::RecordSearch.new(params)
@search.request_url = request.original_url
@search.scope = current_user
begin
if @search.valid?
respond_with @search, serializer: RecordSearchSerializer
else
render request.format.to_sym => { errors: @search.errors }, status: :bad_request
end
rescue RSolr::Error::Http => e
render request.format.to_sym => { errors: solr_error_message(e) }, status: :bad_request
rescue Sunspot::UnrecognizedFieldError => e
render request.format.to_sym => { errors: e.to_s }, status: :bad_request
end
end
|
#multiple ⇒ Object
46
47
48
49
|
# File 'app/controllers/supplejack_api/records_controller.rb', line 46
def multiple
@records = Record.find_multiple(params[:record_ids])
respond_with @records
end
|
#show ⇒ Object
39
40
41
42
43
44
|
# File 'app/controllers/supplejack_api/records_controller.rb', line 39
def show
@record = SupplejackApi::Record.custom_find(params[:id], current_user, params[:search])
respond_with @record, serializer: RecordSerializer
rescue Mongoid::Errors::DocumentNotFound
render request.format.to_sym => { errors: "Record with ID #{params[:id]} was not found" }, status: :not_found
end
|
#status ⇒ Object
35
36
37
|
# File 'app/controllers/supplejack_api/records_controller.rb', line 35
def status
render nothing: true
end
|