Sha256: 43d158d5b956344213cf380b1be062a6c086f6bd3b67fcd109177d396fc42876

Contents?: true

Size: 1.48 KB

Versions: 104

Compression:

Stored size: 1.48 KB

Contents

module Api::V1::Memberships::ControllerBase
  extend ActiveSupport::Concern

  module StrongParameters
    # Only allow a list of trusted parameters through.
    def membership_params
      strong_params = params.require(:membership).permit(
        *permitted_fields,
        :user_first_name,
        :user_last_name,
        # 🚅 super scaffolding will insert new fields above this line.
        *permitted_arrays,
        # 🚅 super scaffolding will insert new arrays above this line
      )

      process_params(strong_params)

      strong_params
    end
  end

  included do
    load_and_authorize_resource :membership, class: "Membership", prepend: true,
      member_actions: (defined?(MEMBER_ACTIONS) ? MEMBER_ACTIONS : []),
      collection_actions: (defined?(COLLECTION_ACTIONS) ? COLLECTION_ACTIONS : [])

    private

    include StrongParameters
  end

  # GET /api/v1/teams/:team_id/memberships
  def index
  end

  # GET /api/v1/memberships/:id
  def show
  end

  # POST /api/v1/teams/:team_id/memberships
  def create
    if @membership.save
      render :show, status: :created, location: [:api, :v1, @membership]
    else
      render json: @membership.errors, status: :unprocessable_entity
    end
  end

  # PUT /api/v1/memberships/:id
  def update
    if @membership.update(membership_params)
      render :show
    else
      render json: @membership.errors, status: :unprocessable_entity
    end
  end

  # DELETE /api/v1/memberships/:id
  def destroy
    @membership.destroy
  end
end

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
bullet_train-api-1.14.0 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.13.0 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.12.3 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.12.2 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.12.1 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.12.0 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.11.0 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.10.0 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.9.0 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.8.5 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.8.4 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.8.3 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.8.2 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.8.1 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.8.0 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.7.23 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.7.22 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.7.21 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.7.20 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.7.19 app/controllers/concerns/api/v1/memberships/controller_base.rb