Sha256: b3d489970ac7440e6d9f646f5cb3d9d1392d153535d69b340ae8150f9a9e2e2d

Contents?: true

Size: 600 Bytes

Versions: 3

Compression:

Stored size: 600 Bytes

Contents

module ElocalApiSupport
  module Actions
    module Update
      def update
        params.permit!
        if lookup_object.update_attributes(parameters_available_for_update)
          render json: lookup_object
        else
          render json:  { errors: lookup_object.errors }, status: 422
        end
      end

      private

      def parameters_available_for_update
        params[associated_model_name].reject { |(k, _v)| k.in?(parameters_to_ignore_from_update) }
      end

      def parameters_to_ignore_from_update
        %w(id created_at updated_at).freeze
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
elocal_api_support-0.1.8 lib/elocal_api_support/actions/update.rb
elocal_api_support-0.1.7 lib/elocal_api_support/actions/update.rb
elocal_api_support-0.1.5 lib/elocal_api_support/actions/update.rb