Class: JSONAPI::RelationshipsController
- Inherits:
-
BaseController
- Object
- BaseController
- JSONAPI::RelationshipsController
- Includes:
- JSONAPI::Relationships::Events, JSONAPI::Relationships::Removal, JSONAPI::Relationships::ResponseHelpers, JSONAPI::Relationships::Serialization, JSONAPI::Relationships::Sorting, JSONAPI::Relationships::Updating
- Defined in:
- lib/json_api/controllers/relationships_controller.rb
Instance Method Summary collapse
Methods included from ResourceActions
#build_resource_for_create, #create, #handle_create_exception, #index
Methods included from JSONAPI::ResourceActions::TypeValidation
#validate_resource_id!, #validate_resource_type!
Methods included from JSONAPI::ResourceActions::Serialization
#serialize_collection, #serialize_resource
Methods included from JSONAPI::ResourceActions::Preloading
Methods included from JSONAPI::ResourceActions::FieldValidation
#validate_fields_param, #validate_include_param, #validate_sort_param
Methods included from JSONAPI::ResourceActions::FilterValidation
Methods included from ActiveStorageSupport
#active_storage_attachment?, #append_only_enabled?, #attach_active_storage_files, #extract_active_storage_params_from_hash, #filter_active_storage_from_includes, #filter_polymorphic_from_includes, #find_blob_by_signed_id, #process_active_storage_attachment, #purge_on_nil_enabled?, #resolve_model_class_for_attachment, #serialize_active_storage_relationship, #serialize_blob_identifier
Methods included from ControllerHelpers::Authorization
Instance Method Details
#destroy ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/json_api/controllers/relationships_controller.rb', line 47 def destroy (@resource, action: :update, context: { relationship: @relationship_name }) relationship_data = parse_relationship_data return head :no_content if relationship_data.nil? remove_relationship(relationship_data) finalize_relationship_removal(relationship_data) rescue ArgumentError => e render_invalid_relationship_error(e) rescue JSONAPI::Exceptions::ParameterNotAllowed => e render_parameter_not_allowed_error(e) end |
#show ⇒ Object
31 32 33 34 |
# File 'lib/json_api/controllers/relationships_controller.rb', line 31 def show (@resource, action: :show, context: { relationship: @relationship_name }) render json: build_show_response, status: :ok end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/json_api/controllers/relationships_controller.rb', line 36 def update (@resource, action: :update, context: { relationship: @relationship_name }) relationship_data = parse_relationship_data update_relationship(relationship_data) save_and_render_relationship(relationship_data) rescue ArgumentError => e render_invalid_relationship_error(e) rescue JSONAPI::Exceptions::ParameterNotAllowed => e render_parameter_not_allowed_error(e) end |