Sha256: 90ec8eb49a5071b8af433cd10698f1f1f11239ccb769040923a5aef20e53975d

Contents?: true

Size: 793 Bytes

Versions: 5

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true
require_dependency "social_networking/application_controller"

module SocialNetworking
  # Manage OnTheMindStatements.
  class OnTheMindStatementsController < ApplicationController
    def create
      @on_the_mind_statement = OnTheMindStatement.new(sanitized_params)

      if @on_the_mind_statement.save
        render json: Serializers::OnTheMindStatementSerializer
          .new(@on_the_mind_statement).to_serialized
      else
        render json: { error: model_errors }, status: 400
      end
    end

    private

    def sanitized_params
      {
        participant_id: current_participant.id,
        description: params[:description]
      }
    end

    def model_errors
      @on_the_mind_statement.errors.full_messages.join(", ")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
social_networking-0.13.3 app/controllers/social_networking/on_the_mind_statements_controller.rb
social_networking-0.13.2 app/controllers/social_networking/on_the_mind_statements_controller.rb
social_networking-0.13.1 app/controllers/social_networking/on_the_mind_statements_controller.rb
social_networking-0.13.0 app/controllers/social_networking/on_the_mind_statements_controller.rb
social_networking-0.12.0 app/controllers/social_networking/on_the_mind_statements_controller.rb