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.4.7 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.4.6 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.4.5 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.4.4 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.4.3 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.4.2 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.4.1 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.4.0 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.25 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.24 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.23 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.22 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.21 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.20 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.19 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.18 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.17 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.16 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.15 app/controllers/concerns/api/v1/memberships/controller_base.rb
bullet_train-api-1.3.14 app/controllers/concerns/api/v1/memberships/controller_base.rb