Class: SupplejackApi::ConceptsController
Instance Method Summary
collapse
#authenticate_admin!, #authenticate_user!, #current_user, #find_user_set
Instance Method Details
#default_serializer_options ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/supplejack_api/concepts_controller.rb', line 41
def default_serializer_options
default_options = {}
@search ||= SupplejackApi::ConceptSearch.new(params)
default_options[:fields] = @search.field_list if @search.field_list.present?
default_options[:groups] = @search.group_list if @search.group_list.present?
if params[:inline_context].try(:downcase) == 'true'
default_options[:inline_context] = params[:inline_context]
end
default_options
end
|
#index ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/supplejack_api/concepts_controller.rb', line 16
def index
@search = ConceptSearch.new(params)
@search.request_url = request.original_url
@search.scope = current_user
begin
if @search.valid?
respond_with @search, serializer: ConceptSearchSerializer
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
|
#show ⇒ Object
34
35
36
37
38
39
|
# File 'app/controllers/supplejack_api/concepts_controller.rb', line 34
def show
@concept = SupplejackApi::Concept.custom_find(params[:id], current_user, params[:search])
respond_with @concept, root: false, serializer: ConceptSerializer
rescue Mongoid::Errors::DocumentNotFound
render request.format.to_sym => { errors: "Concept with ID #{params[:id]} was not found" }, status: :not_found
end
|