Sha256: 3d698b65a1745a4e87cc59d7c6383a08f64925514f9294df5be9c427a490461b
Contents?: true
Size: 1.16 KB
Versions: 84
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Spree module Api class CreditCardsController < Spree::Api::BaseController before_action :user, only: [:index] before_action :find_credit_card, only: [:update] def index @credit_cards = user .credit_cards .accessible_by(current_ability) .with_payment_profile .ransack(params[:q]).result @credit_cards = paginate(@credit_cards) respond_with(@credit_cards) end def update if @credit_card.update(credit_card_update_params) respond_with(@credit_card, default_template: :show) else invalid_resource!(@credit_card) end end private def user if params[:user_id].present? @user ||= Spree.user_class.accessible_by(current_ability, :show).find(params[:user_id]) end end def find_credit_card @credit_card = Spree::CreditCard.find(params[:id]) authorize! :update, @credit_card end def credit_card_update_params params.require(:credit_card).permit(permitted_credit_card_update_attributes) end end end end
Version data entries
84 entries across 84 versions & 1 rubygems